fix some more memory problems
authorDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 07:52:32 +0000 (02:52 -0500)
committerDana Jansens <danakj@orodu.net>
Wed, 5 Mar 2008 07:52:32 +0000 (02:52 -0500)
dcompmgr.c
render.c
window.c
window.h

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);
+                }
         }
     }
 
index 8d272fb..7950419 100644 (file)
--- a/render.c
+++ b/render.c
@@ -6,6 +6,7 @@
 #include "display.h"
 #include "list.h"
 #include <stdio.h>
+#include <assert.h>
 #include <stdlib.h>
 #include <xcb/render.h>
 
@@ -145,8 +146,6 @@ render_window_hide(d_window_t *w)
         window_remove_plugin_data(w, plugin_id);
     }
 
-    window_unref(w);
-
     /* pass it on */
     d->window_hide(w);
 }
@@ -257,6 +256,7 @@ render_window_resize(d_window_t *w)
 
     d = screen_find_plugin_data(w->sc, plugin_id);
     wd = window_find_plugin_data(w, plugin_id);
+    assert(wd != NULL);
     render_free_picture(w, wd);
 
     /* pass it on */
index f4a97a9..2c55b10 100644 (file)
--- a/window.c
+++ b/window.c
@@ -132,6 +132,7 @@ window_show(d_window_t *pubw)
     d_window_priv_t *w = (d_window_priv_t*)pubw;
 
     window_is_mapped(pubw); /* kill any ongoing request */
+    assert(!w->mapped);
 
     //printf("show window 0x%x\n", w->id);
 
@@ -145,6 +146,7 @@ window_hide(d_window_t *pubw)
     d_window_priv_t *w = (d_window_priv_t*)pubw;
 
     window_is_mapped(pubw); /* kill any ongoing request */
+    assert(w->mapped);
 
     //printf("hide window 0x%x\n", w->id);
 
@@ -152,6 +154,14 @@ window_hide(d_window_t *pubw)
 }
 
 void
+window_fake_unmapped(d_window_t *pubw)
+{
+    d_window_priv_t *w = (d_window_priv_t*)pubw;
+
+    w->mapped = FALSE;
+}
+
+void
 window_become_zombie(d_window_t *pubw)
 {
     d_window_priv_t *w = (d_window_priv_t*)pubw;
@@ -205,6 +215,7 @@ window_get_attributes_reply(d_window_priv_t *w)
         w->input_only = rep->_class == XCB_WINDOW_CLASS_INPUT_ONLY;
         w->mapped = rep->map_state != XCB_MAP_STATE_UNMAPPED;
         w->visual = rep->visual;
+        //printf("0x%x attributes mapped %d\n", w->id, w->mapped);
         free(rep);
     }
     else {
@@ -216,7 +227,7 @@ window_get_attributes_reply(d_window_priv_t *w)
         printf("error getting attributes for window 0x%x\n", w->id);
         free(err);
     }
-    w->waiting_attr = 0;
+    w->waiting_attr = FALSE;
 }
 
 static void
@@ -246,7 +257,7 @@ window_get_geometry_reply(d_window_priv_t *w)
         printf("error getting geometry for window 0x%x\n", w->id);
         free(err);
     }
-    w->waiting_geom = 0;
+    w->waiting_geom = FALSE;
 }
 
 gboolean
index 23cf5d9..59a8749 100644 (file)
--- a/window.h
+++ b/window.h
@@ -18,6 +18,7 @@ void window_unref(d_window_t *w);
 
 void window_show(d_window_t *w);
 void window_hide(d_window_t *w);
+void window_fake_unmapped(d_window_t *w);
 
 void window_become_zombie(d_window_t *w);