fix some more memory problems
[dana/dcompmgr.git] / dcompmgr.c
index 29ec004..b9fde3c 100644 (file)
@@ -75,7 +75,8 @@ event(d_display_t *dpy)
             if (!sc) break;
             w = screen_find_window(sc, dev->window);
             vis = window_is_mapped(w);
-            sc->window_hide(w);
+            if (vis)
+                sc->window_hide(w);
             screen_remove_window(sc, w);
             if (vis) screen_refresh(sc);
             break;
@@ -93,7 +94,8 @@ event(d_display_t *dpy)
             if (rev->parent == sc->super.root)
                 screen_add_window(sc, rev->window);
             else {
-                sc->window_hide(w);
+                if (window_is_mapped(w))
+                    sc->window_hide(w);
                 screen_remove_window(sc, w);
             }
             screen_refresh(w->sc);
@@ -137,6 +139,7 @@ event(d_display_t *dpy)
             cev = (xcb_configure_notify_event_t*)ev;
             sc = display_screen_from_root(dpy, cev->event);
             if (!sc) break;
+            //printf("configure 0x%x", cev->window);
             w = screen_find_window(sc, cev->window);
             window_get_area(w, &x, &y, &width, &height, &bwidth);
             if (x != cev->x || y != cev->y || width != cev->width ||
@@ -145,10 +148,13 @@ event(d_display_t *dpy)
                 window_configure(w, cev->x, cev->y,
                                  cev->width, cev->height,
                                  cev->border_width);
-                if (window_is_mapped(w) &&
-                    (width != cev->width ||
-                     height != cev->height || bwidth != cev->border_width))
-                    sc->window_resize(w);
+                if (window_is_mapped(w)) {
+                    if (x != cev->x || y != cev->y)
+                        sc->window_move(w);
+                    if (width != cev->width ||
+                        height != cev->height || bwidth != cev->border_width)
+                        sc->window_resize(w);
+                }
             }
             above = screen_find_window(sc, cev->above_sibling);
             screen_stacking_move_above(sc, w, above);
@@ -344,8 +350,12 @@ main(int argc, char **argv)
             d_screen_t *sc = sc_it->data;
             d_list_it_t *it;
             for (it = list_bottom(sc->stacking); it; it = it->prev)
-                if (window_is_mapped(it->data))
+                if (window_is_mapped(it->data)) {
+                    /* make the window think it is unmapped so that the
+                       show works right */
+                    window_fake_unmapped(it->data);
                     sc->window_show(it->data);
+                }
         }
     }