add windows to the stacking order when they are created, and allow zombie windows...
[dana/dcompmgr.git] / window.c
index 4d9bb7b..83efdf3 100644 (file)
--- a/window.c
+++ b/window.c
@@ -1,7 +1,13 @@
 #include "window.h"
+#include "screen.h"
 #include <stdlib.h>
 #include <stdio.h>
 
+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;
+}