fix some memory problems
[dana/dcompmgr.git] / dcompmgr.c
index 7067a11..29ec004 100644 (file)
@@ -1,3 +1,5 @@
+#include "efence.h"
+
 #include "screen.h"
 #include "window.h"
 #include "list.h"
@@ -59,7 +61,6 @@ event(d_display_t *dpy)
             sc = display_screen_from_root(dpy, cev->parent);
             if (!sc) break;
             w = screen_add_window(sc, cev->window);
-            printf("created 0x%x\n", w);
             break;
         }
         case XCB_DESTROY_NOTIFY:
@@ -73,7 +74,6 @@ event(d_display_t *dpy)
             sc = display_screen_from_root(dpy, dev->event);
             if (!sc) break;
             w = screen_find_window(sc, dev->window);
-            printf("destroyed 0x%x\n", w);
             vis = window_is_mapped(w);
             sc->window_hide(w);
             screen_remove_window(sc, w);
@@ -95,7 +95,6 @@ event(d_display_t *dpy)
             else {
                 sc->window_hide(w);
                 screen_remove_window(sc, w);
-                printf("reparent lost 0x%x\n", w);
             }
             screen_refresh(w->sc);
             break;
@@ -110,7 +109,6 @@ event(d_display_t *dpy)
             sc = display_screen_from_root(dpy, mev->event);
             if (!sc) break;
             w = screen_find_window(sc, mev->window);
-            printf("mapping 0x%x\n", w);
             sc->window_show(w);
             screen_refresh(w->sc);
             break;
@@ -345,7 +343,7 @@ main(int argc, char **argv)
         for (sc_it = list_top(dpy->screens); sc_it; sc_it = sc_it->next) {
             d_screen_t *sc = sc_it->data;
             d_list_it_t *it;
-            for (it = list_top(sc->stacking); it; it = it->next)
+            for (it = list_bottom(sc->stacking); it; it = it->prev)
                 if (window_is_mapped(it->data))
                     sc->window_show(it->data);
         }
@@ -360,8 +358,10 @@ main(int argc, char **argv)
         for (sc_it = list_top(dpy->screens); sc_it; sc_it = sc_it->next) {
             d_screen_t *sc = sc_it->data;
             d_list_it_t *it;
-            for (it = list_top(sc->stacking); it; it = it->next)
-                sc->window_hide(it->data);
+            for (it = list_top(sc->stacking); it; it = it->next) {
+                if (window_is_mapped(it->data))
+                    sc->window_hide(it->data);
+            }
         }
     }