add "mapped" and "area" to obwin so the composite can get sizes right and properly...
authorDerek Foreman <foremande@gmail.com>
Thu, 10 Jun 2010 02:59:53 +0000 (22:59 -0400)
committerDana Jansens <danakj@orodu.net>
Sat, 26 Jun 2010 23:30:46 +0000 (01:30 +0200)
openbox/composite.c
openbox/event.c
openbox/window.h

index 7675a42..af24f2f 100644 (file)
@@ -60,7 +60,6 @@ static void get_best_fbcon(GLXFBConfig *in, int count, int depth, GLXFBConfig *o
     int i, value, has_alpha;
 
     for (i = 0; i < count; i++) {
-
         vi = glXGetVisualFromFBConfig(obt_display, in[i]);
         if (vi == NULL)
             continue;
@@ -229,7 +228,7 @@ void composite_startup(gboolean reconfig)
 
     memset(&obcomp.PixmapConfig, 0, sizeof(obcomp.PixmapConfig));
 
-    for (i = 0; i < MAX_DEPTH + 1; i++) {
+    for (i = 1; i < MAX_DEPTH + 1; i++) {
         get_best_fbcon(fbcs, count, i, &obcomp.PixmapConfig[i]);
     }
 
@@ -291,13 +290,18 @@ static gboolean composite(gpointer data)
 //    for (it = stacking_list; it; it = g_list_next(it)) {
     for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) {
         win = it->data;
-        if (win->type != OB_WINDOW_CLASS_CLIENT)
+        if (win->type == OB_WINDOW_CLASS_PROMPT)
             continue;
 
-        client = WINDOW_AS_CLIENT(win);
-        if (client->desktop != screen_desktop)
+        if (!win->mapped)
             continue;
 
+        if (win->type == OB_WINDOW_CLASS_CLIENT) {
+            client = WINDOW_AS_CLIENT(win);
+            if (client->desktop != screen_desktop)
+                continue;
+        }
+
         if (win->depth == 32)
             attribs[1] = GLX_TEXTURE_FORMAT_RGBA_EXT;
         else
@@ -325,13 +329,13 @@ time_fix(&dif);
 
         glBegin(GL_QUADS);
         glTexCoord2f(0, 0);
-        glVertex3f(client->frame->area.x, client->frame->area.y, 0.0);
+        glVertex3f(win->comp_area.x, win->comp_area.y, 0.0);
         glTexCoord2f(0, 1);
-        glVertex3f(client->frame->area.x, client->frame->area.y + client->frame->area.height, 0.0);
+        glVertex3f(win->comp_area.x, win->comp_area.y + win->comp_area.height, 0.0);
         glTexCoord2f(1, 1);
-        glVertex3f(client->frame->area.x + client->frame->area.width, client->frame->area.y + client->frame->area.height, 0.0);
+        glVertex3f(win->comp_area.x + win->comp_area.width, win->comp_area.y + win->comp_area.height, 0.0);
         glTexCoord2f(1, 0);
-        glVertex3f(client->frame->area.x + client->frame->area.width, client->frame->area.y, 0.0);
+        glVertex3f(win->comp_area.x + win->comp_area.width, win->comp_area.y, 0.0);
         glEnd();
     }
     glXSwapBuffers(obt_display, obcomp.overlay);
index 871d0e8..115e288 100644 (file)
@@ -43,7 +43,7 @@
 #include "obt/xqueue.h"
 #include "obt/prop.h"
 #include "obt/keyboard.h"
-
+#include "geom.h"
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 #include <glib.h>
@@ -622,19 +622,49 @@ static void event_process(const XEvent *ec, gpointer data)
             frame_adjust_focus(client->frame, FALSE);
     }
 #ifdef USE_COMPOSITING
-    else if ((e->type == ConfigureNotify || e->type == MapNotify)
+    else if ((e->type == CreateNotify) && obwin
+             && obwin->type != OB_WINDOW_CLASS_PROMPT) {
+        XCreateWindowEvent const *xe = &e->xcreatewindow;
+        if (xe->window == window_top(obwin)) {
+            obwin->mapped = 0;
+            RECT_SET(obwin->comp_area, xe->x, xe->y, xe->width, xe->height);
+        }
+    } else if ((e->type == ConfigureNotify || e->type == MapNotify)
              && obwin && obwin->type != OB_WINDOW_CLASS_PROMPT) {
-        if (obwin->pixmap != None) {
-            XFreePixmap(obt_display, obwin->pixmap);
-            obwin->pixmap = None;
+        gboolean pixchange = FALSE;
+
+        if (e->type == ConfigureNotify) {
+            XConfigureEvent const *xe = &e->xconfigure;
+            if (xe->window == window_top(obwin)) {
+                if ((obwin->comp_area.width != xe->width)
+                    || (obwin->comp_area.height != xe->height))
+                    pixchange = TRUE;
+                RECT_SET(obwin->comp_area, xe->x, xe->y, xe->width, xe->height);
+            }
         }
-        if (obwin->gpixmap != None) {
-            glXDestroyGLXPixmap(obt_display, obwin->gpixmap);
-            obwin->gpixmap = None;
+
+        if (e->type == MapNotify) {
+            XMapEvent const *xe = &e->xmap;
+            if (xe->window == window_top(obwin)) {
+                pixchange = TRUE;
+                obwin->mapped = TRUE;
+            }
         }
 
-//XXX actually need to check if this was just a move and not re-make the pmap!
-//printf("win %d has pixmap %d\n", window_top(obwin), obwin->pixmap);
+        if (pixchange) {
+            if (obwin->pixmap != None) {
+                XFreePixmap(obt_display, obwin->pixmap);
+                obwin->pixmap = None;
+            }
+            if (obwin->gpixmap != None) {
+                glXDestroyGLXPixmap(obt_display, obwin->gpixmap);
+                obwin->gpixmap = None;
+            }
+        }
+    } else if ((e->type == UnmapNotify) && obwin
+             && obwin->type != OB_WINDOW_CLASS_PROMPT) {
+            if (e->xunmap.window == window_top(obwin))
+                obwin->mapped = FALSE;
     }
 #endif
     else if (client)
index 74b9c08..df37332 100644 (file)
@@ -20,6 +20,7 @@
 #define __window_h
 
 #include "stacking.h"
+#include "geom.h"
 
 #include <X11/Xlib.h>
 #include <glib.h>
@@ -51,6 +52,8 @@ struct _ObWindow {
     GLXPixmap gpixmap;
     Damage damage;
     int depth;
+    Rect comp_area;
+    gboolean mapped;
 #endif
 };