free the screen's stuff properly. add a stacking list to the screen.
authorDana Jansens <danakj@orodu.net>
Tue, 4 Mar 2008 22:33:26 +0000 (17:33 -0500)
committerDana Jansens <danakj@orodu.net>
Tue, 4 Mar 2008 22:43:06 +0000 (17:43 -0500)
display.c
screen.c
screen.h

index be05baf..3eefc56 100644 (file)
--- a/display.c
+++ b/display.c
@@ -191,7 +191,11 @@ void
 display_unref(d_display_t *dpy)
 {
     if (dpy && --dpy->ref == 0) {
+        int i;
         xcb_disconnect(dpy->conn);
+
+        for (i = 0; i < dpy->nscreens; ++i)
+            screen_free(&dpy->screens[i]);
         free(dpy->screens);
         free(dpy);
     }
index dfad6e4..15827ff 100644 (file)
--- a/screen.c
+++ b/screen.c
@@ -1,5 +1,6 @@
 #include "screen.h"
 #include "display.h"
+#include "list.h"
 #include "window.h"
 #include "gettext.h"
 #include <string.h>
@@ -92,9 +93,6 @@ screen_init(d_screen_t *sc)
     xcb_composite_get_overlay_window_cookie_t overlay_ck;
     xcb_composite_get_overlay_window_reply_t *overlay_rep;
 
-    sc->winhash = g_hash_table_new((GHashFunc)window_hash,
-                                   (GCompareFunc)window_compare);
-
     redir_ck =
         xcb_composite_redirect_subwindows(sc->dpy->conn, sc->super.root,
                                           XCB_COMPOSITE_REDIRECT_MANUAL);
@@ -127,9 +125,20 @@ screen_init(d_screen_t *sc)
     mask = ROOT_MASK;
     xcb_change_window_attributes(sc->dpy->conn, sc->super.root,
                                  XCB_CW_EVENT_MASK, &mask);
+
+    sc->winhash = g_hash_table_new((GHashFunc)window_hash,
+                                   (GCompareFunc)window_compare);
+    sc->stacking = list_new();
+
     return TRUE;
 }
 
+void screen_free(d_screen_t *sc)
+{
+    g_hash_table_unref(sc->winhash);
+    list_unref(sc->stacking);
+}
+
 void
 screen_add_window(d_screen_t *sc, xcb_window_t wid)
 {
index 5317599..84798c9 100644 (file)
--- a/screen.h
+++ b/screen.h
@@ -6,6 +6,7 @@
 
 struct d_window;
 struct d_display;
+struct d_list;
 
 /* inherits from xcb_screen_t */
 typedef struct d_screen {
@@ -19,12 +20,14 @@ typedef struct d_screen {
     xcb_window_t      overlay;
 
     GHashTable       *winhash;
+    struct d_list    *stacking;
 } d_screen_t;
 
 /*! Tries to register on the screen given by @sc.  If it succeeds, it fills
     in @sc and returns TRUE, otherwise it returns FALSE.
 */
 gboolean screen_register(struct d_display *dpy, int num, d_screen_t *sc);
+void screen_free(d_screen_t *sc);
 
 void screen_add_window(d_screen_t *sc, xcb_window_t wid);
 void screen_remove_window(d_screen_t *sc, struct d_window *w);