make sure that when a window is shown it stops being a zombie
[dana/dcompmgr.git] / fade.c
diff --git a/fade.c b/fade.c
index 9ba6c49..3ce8ab3 100644 (file)
--- a/fade.c
+++ b/fade.c
@@ -36,7 +36,8 @@ typedef struct {
 
 static void fade_window_show(d_window_t *w);
 static void fade_window_hide(d_window_t *w);
 
 static void fade_window_show(d_window_t *w);
 static void fade_window_hide(d_window_t *w);
-static void start_fade(d_window_t *w, uint16_t start, uint16_t end);
+static void start_fade(d_window_t *w, uint16_t start_alpha, uint16_t end_alpha,
+                       gboolean refalways);
 
 void
 fade_init(d_screen_t *sc, int id)
 
 void
 fade_init(d_screen_t *sc, int id)
@@ -53,7 +54,7 @@ fade_init(d_screen_t *sc, int id)
 
     d->fades = list_new();
     d->fade_step_time = 5000;     /* 5 milliseconds */
 
     d->fades = list_new();
     d->fade_step_time = 5000;     /* 5 milliseconds */
-    d->fade_total_time = 166000;  /* 0.15 seconds */
+    d->fade_total_time = 180000;  /* 0.18 seconds */
 }
 
 void
 }
 
 void
@@ -80,12 +81,24 @@ static void
 fade_window_show(d_window_t *w)
 {
     data_t *d;
 fade_window_show(d_window_t *w)
 {
     data_t *d;
-
-    if (!window_is_input_only(w))
-        start_fade(w, 0x0000, 0xffff);
+    d_list_it_t *it;
 
     d = screen_find_plugin_data(w->sc, plugin_id);
 
     d = screen_find_plugin_data(w->sc, plugin_id);
+
+    /* kill the zombies off cuz a new copy is being shown */
+    for (it = list_top(d->fades); it; it = it->next) {
+        fade_t *fade = it->data;
+        if (fade->w == w) {
+            window_zombie_unref(w);
+            window_unref(w);
+            break;
+        }
+    }
+
     d->window_show(w);    
     d->window_show(w);    
+
+    if (!window_is_input_only(w))
+        start_fade(w, 0x2000, 0xffff, TRUE);
 }
 
 static void
 }
 
 static void
@@ -94,14 +107,15 @@ fade_window_hide(d_window_t *w)
     data_t *d;
 
     if (!window_is_input_only(w))
     data_t *d;
 
     if (!window_is_input_only(w))
-        start_fade(w, 0xffff, 0x0000);
+        start_fade(w, 0xffff, 0x0002, FALSE);
 
     d = screen_find_plugin_data(w->sc, plugin_id);
     d->window_hide(w);
 }
 
 static void
 
     d = screen_find_plugin_data(w->sc, plugin_id);
     d->window_hide(w);
 }
 
 static void
-start_fade(d_window_t *w, uint16_t start_alpha, uint16_t end_alpha)
+start_fade(d_window_t *w, uint16_t start_alpha, uint16_t end_alpha,
+           gboolean refalways)
 {
     data_t *d;
     d_list_it_t *it;
 {
     data_t *d;
     d_list_it_t *it;
@@ -142,9 +156,6 @@ start_fade(d_window_t *w, uint16_t start_alpha, uint16_t end_alpha)
         fade->current_alpha = start_alpha;
 
         window_set_opacity(w, fade->current_alpha);
         fade->current_alpha = start_alpha;
 
         window_set_opacity(w, fade->current_alpha);
-
-        window_ref(w);
-        window_zombie_ref(w);
     }
     else {
         /* figure out how far we have to go to finish the fade from where
     }
     else {
         /* figure out how far we have to go to finish the fade from where
@@ -165,6 +176,10 @@ start_fade(d_window_t *w, uint16_t start_alpha, uint16_t end_alpha)
         fade->end_time = now;
         time_add(&fade->end_time, percent*d->fade_total_time);
     }
         fade->end_time = now;
         time_add(&fade->end_time, percent*d->fade_total_time);
     }
+    if (newfade || refalways) {
+        window_zombie_ref(w);
+        window_ref(w);
+    }
 }
 
 int
 }
 
 int