From: Dana Jansens Date: Tue, 4 Mar 2008 22:41:59 +0000 (-0500) Subject: add windows to the stacking order when they are created, and allow zombie windows... X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=153c8638b8fd402e0b8a9518d39a394eb84da1ed;p=dana%2Fdcompmgr.git add windows to the stacking order when they are created, and allow zombie windows, which also live in the stacking order --- diff --git a/dcompmgr.c b/dcompmgr.c index 2c1c50c..6b8417a 100644 --- a/dcompmgr.c +++ b/dcompmgr.c @@ -130,7 +130,7 @@ main(int argc, char **argv) sc = display_screen_from_root(dpy, mev->event); if (!sc) break; w = screen_find_window(sc, mev->window); - window_show(w); + w->show(w); break; } case XCB_UNMAP_NOTIFY: @@ -143,7 +143,7 @@ main(int argc, char **argv) sc = display_screen_from_root(dpy, mev->event); if (!sc) break; w = screen_find_window(sc, mev->window); - window_hide(w); + w->hide(w); break; } default: diff --git a/list.c b/list.c index 83ae21e..2557bc9 100644 --- a/list.c +++ b/list.c @@ -116,6 +116,13 @@ list_move_before(d_list_t *list, d_list_it_t *move, d_list_it_t *before) if (!move->prev) list->top = move; } +void +list_remove(d_list_t *list, void *data) +{ + d_list_it_t *it = list_find(list, data); + if (it) list_delete_link(list, it); +} + int list_length(d_list_t *list) { @@ -148,3 +155,13 @@ list_nth(d_list_t *list, int n) it = it->next; return it; } + +d_list_it_t* +list_find(d_list_t *list, void *data) +{ + d_list_it_t *it; + + for (it = list->top; it; it = it->next) + if (it->data == data) return it; + return NULL; +} diff --git a/list.h b/list.h index f35ae8b..737f68d 100644 --- a/list.h +++ b/list.h @@ -21,10 +21,12 @@ void list_unref(d_list_t *list); d_list_it_t* list_prepend(d_list_t *list, void *data); void list_delete_link(d_list_t *list, d_list_it_t *pos); void list_move_before(d_list_t *list, d_list_it_t *move, d_list_it_t *before); +void list_remove(d_list_t *list, void *data); int list_length(d_list_t *list); d_list_it_t* list_top(d_list_t *list); d_list_it_t* list_bottom(d_list_t *list); d_list_it_t* list_nth(d_list_t *list, int n); +d_list_it_t* list_find(d_list_t *list, void *data); #endif diff --git a/screen.c b/screen.c index 15827ff..775d277 100644 --- a/screen.c +++ b/screen.c @@ -158,6 +158,7 @@ screen_remove_window(d_screen_t *sc, struct d_window *w) printf("screen removed window 0x%x\n", w->id); g_hash_table_remove(sc->winhash, &w->id); + w->become_zombie(w); window_unref(w); } @@ -203,3 +204,15 @@ screen_timestamp(d_screen_t *sc) printf("created timestamp %lu\n", (unsigned long) time); return time; } + +void +screen_stacking_add(d_screen_t *sc, struct d_window *w) +{ + list_prepend(sc->stacking, w); +} + +void +screen_stacking_remove(d_screen_t *sc, struct d_window *w) +{ + list_remove(sc->stacking, w); +} diff --git a/screen.h b/screen.h index 84798c9..5a8ef8d 100644 --- a/screen.h +++ b/screen.h @@ -34,4 +34,7 @@ void screen_remove_window(d_screen_t *sc, struct d_window *w); struct d_window* screen_find_window(d_screen_t *sc, xcb_window_t id); +void screen_stacking_add(d_screen_t *sc, struct d_window *w); +void screen_stacking_remove(d_screen_t *sc, struct d_window *w); + #endif diff --git a/window.c b/window.c index 4d9bb7b..83efdf3 100644 --- a/window.c +++ b/window.c @@ -1,7 +1,13 @@ #include "window.h" +#include "screen.h" #include #include +static void window_show(d_window_t *w); +static void window_hide(d_window_t *w); + +static void window_become_zombie(d_window_t *w); + d_window_t* window_new(xcb_window_t id, struct d_screen *sc) { @@ -12,10 +18,14 @@ window_new(xcb_window_t id, struct d_screen *sc) w->ref = 1; w->sc = sc; w->mapped = FALSE; + w->zombie = FALSE; /* default functions */ w->show = window_show; w->hide = window_hide; + w->become_zombie = window_become_zombie; + + screen_stacking_add(sc, w); printf("new window 0x%x\n", w->id); @@ -32,11 +42,12 @@ void window_unref(d_window_t *w) { if (w && --w->ref == 0) { + screen_stacking_remove(w->sc, w); free(w); } } -void +static void window_show(d_window_t *w) { if (w->mapped) return; @@ -46,7 +57,7 @@ window_show(d_window_t *w) w->mapped = TRUE; } -void +static void window_hide(d_window_t *w) { if (!w->mapped) return; @@ -55,3 +66,11 @@ window_hide(d_window_t *w) w->mapped = FALSE; } + +static void +window_become_zombie(d_window_t *w) +{ + if (w->zombie) return; + + w->zombie = TRUE; +} diff --git a/window.h b/window.h index 211fd8e..33542ba 100644 --- a/window.h +++ b/window.h @@ -12,9 +12,11 @@ typedef struct d_window { struct d_screen *sc; gboolean mapped; + gboolean zombie; void (*show)(struct d_window *w); void (*hide)(struct d_window *w); + void (*become_zombie)(struct d_window *w); } d_window_t; d_window_t* window_new(xcb_window_t id, struct d_screen *sc); @@ -22,7 +24,4 @@ d_window_t* window_new(xcb_window_t id, struct d_screen *sc); void window_ref(d_window_t *w); void window_unref(d_window_t *w); -void window_show(d_window_t *w); -void window_hide(d_window_t *w); - #endif