handle configure notify events
authorDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 02:32:24 +0000 (21:32 -0500)
committerDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 02:32:24 +0000 (21:32 -0500)
dcompmgr.c
screen.c
screen.h
window.c
window.h

index 26363c4..f9d1ebb 100644 (file)
@@ -54,15 +54,16 @@ event(d_display_t *dpy)
             xcb_destroy_notify_event_t *dev;
             d_screen_t *sc;
             d_window_t *w;
+            gboolean vis;
 
             dev = (xcb_destroy_notify_event_t*)ev;
             sc = display_screen_from_root(dpy, dev->event);
             if (!sc) break;
             w = screen_find_window(sc, dev->window);
+            vis = window_is_mapped(w);
             sc->window_hide(w);
             screen_remove_window(sc, w);
-            printf("** refresh needed **\n");
-            screen_refresh(sc);
+            if (vis) screen_refresh(sc);
             break;
         }
         case XCB_REPARENT_NOTIFY:
@@ -81,6 +82,7 @@ event(d_display_t *dpy)
                 sc->window_hide(w);
                 screen_remove_window(sc, w);
             }
+            screen_refresh(w->sc);
             break;
         }
         case XCB_MAP_NOTIFY:
@@ -94,6 +96,7 @@ event(d_display_t *dpy)
             if (!sc) break;
             w = screen_find_window(sc, mev->window);
             sc->window_show(w);
+            screen_refresh(w->sc);
             break;
         }
         case XCB_UNMAP_NOTIFY:
@@ -107,6 +110,24 @@ event(d_display_t *dpy)
             if (!sc) break;
             w = screen_find_window(sc, mev->window);
             sc->window_hide(w);
+            screen_refresh(w->sc);
+            break;
+        }
+        case XCB_CONFIGURE_NOTIFY:
+        {
+            xcb_configure_notify_event_t *cev;
+            d_screen_t *sc;
+            d_window_t *w, *above;
+
+            cev = (xcb_configure_notify_event_t*)ev;
+            sc = display_screen_from_root(dpy, cev->event);
+            if (!sc) break;
+            w = screen_find_window(sc, cev->window);
+            sc->window_configure(w, cev->x, cev->y,
+                                 cev->width, cev->height, cev->border_width);
+            above = screen_find_window(sc, cev->above_sibling);
+            screen_stacking_move_above(sc, w, above);
+            screen_refresh(w->sc);
             break;
         }
         default:
index 5a588d3..ada1b4f 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -279,6 +279,15 @@ screen_stacking_remove(d_screen_t *sc, struct d_window *w)
     list_remove(sc->stacking, w);
 }
 
+void
+screen_stacking_move_above(d_screen_t *sc, struct d_window *w,
+                           struct d_window *above)
+{
+    d_list_it_t *wit = list_find(sc->stacking, w);
+    d_list_it_t *ait = list_find(sc->stacking, above);
+    list_move_before(sc->stacking, wit, ait);
+}
+
 static void
 screen_set_next_repaint(d_screen_t *sc)
 {
@@ -295,7 +304,7 @@ screen_setup_default_functions(d_screen_t *sc)
     sc->window_show = window_show;
     sc->window_hide = window_hide;
     sc->window_become_zombie = window_become_zombie;
-
+    sc->window_configure = window_configure;
 }
 
 void
index 4c6d5c8..5d46555 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -33,6 +33,8 @@ typedef struct d_screen {
     void (*window_show)(struct d_window *w);
     void (*window_hide)(struct d_window *w);
     void (*window_become_zombie)(struct d_window *w);
+    void (*window_configure)(struct d_window *w, int x, int y,
+                             int width, int height, int border_width);
 } d_screen_t;
 
 d_screen_t* screen_new(struct d_display *dpy, int num, xcb_screen_t *xcb);
@@ -52,6 +54,8 @@ struct d_window* screen_find_window(d_screen_t *sc, xcb_window_t id);
 
 void screen_stacking_add(d_screen_t *sc, struct d_window *w);
 void screen_stacking_remove(d_screen_t *sc, struct d_window *w);
+void screen_stacking_move_above(d_screen_t *sc, struct d_window *w,
+                                struct d_window *above);
 
 void screen_setup_default_functions(d_screen_t *sc);
 
index 658d10f..9c7847e 100644 (file)
--- a/window.c
+++ b/window.c
@@ -225,6 +225,7 @@ xcb_pixmap_t
 window_get_pixmap(d_window_t *pubw)
 {
     d_window_priv_t *w = (d_window_priv_t*)pubw;
+
     if (w->ck_get_pixmap.sequence) {
         xcb_generic_error_t *err;
         //printf("** checking get pixmap 0x%x\n", w->id);
@@ -238,3 +239,18 @@ window_get_pixmap(d_window_t *pubw)
     //printf("returning pixmap 0x%x for window 0x%x\n", w->pixmap, w->id);
     return w->pixmap;
 }
+
+void
+window_configure(d_window_t *pubw, int x, int y, int width, int height,
+                 int border_width)
+{
+    d_window_priv_t *w = (d_window_priv_t*)pubw;
+
+    /* this overrides any reply from our get_geometry call */
+    if (w->ck_get_geom.sequence)
+        w->ck_get_geom.sequence = 0;
+    w->x = x;
+    w->y = y;
+    w->w = width + border_width * 2;
+    w->h = height + border_width * 2;
+}
index c0484cb..b86f587 100644 (file)
--- a/window.h
+++ b/window.h
@@ -24,6 +24,9 @@ void window_hide(d_window_t *w);
 
 void window_become_zombie(d_window_t *w);
 
+void window_configure(d_window_t *w, int x, int y, int width, int height,
+                      int border_width);
+
 gboolean window_is_zombie(d_window_t *w);
 gboolean window_is_input_only(d_window_t *w);
 gboolean window_is_mapped(d_window_t *w);