From c07857764ac7425ca53b6d4c608a74397ce999f3 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 4 Mar 2008 17:33:26 -0500 Subject: [PATCH] free the screen's stuff properly. add a stacking list to the screen. --- display.c | 4 ++++ screen.c | 15 ++++++++++++--- screen.h | 3 +++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/display.c b/display.c index be05baf..3eefc56 100644 --- 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); } diff --git a/screen.c b/screen.c index dfad6e4..15827ff 100644 --- 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 @@ -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) { diff --git a/screen.h b/screen.h index 5317599..84798c9 100644 --- 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); -- 1.9.1