don't fade on startup/shutdown, make fading a bit quicker
[dana/dcompmgr.git] / dcompmgr.c
index 8fa0b28..8dcaa1f 100644 (file)
@@ -26,6 +26,7 @@ typedef struct {
 } d_options_t;
 
 static gboolean quit = FALSE;
+static gboolean running = FALSE;
 
 static void
 read_options(int argc, char **argv, d_options_t *opts)
@@ -182,7 +183,8 @@ event(d_display_t *dpy)
                 }
             }
             above = screen_find_window(sc, cev->above_sibling);
-            screen_stacking_move_above(sc, w, above);
+            if (window_is_mapped(w))
+                sc->window_restack(w, above);
             screen_refresh(w->sc);
             break;
         }
@@ -232,6 +234,7 @@ event(d_display_t *dpy)
 
                     w = screen_find_window(sc, dev->drawable);
                     if (w) {
+                        sc->window_damage(w);
                         screen_refresh(w->sc);
                         break;
                     }
@@ -251,7 +254,7 @@ event(d_display_t *dpy)
                     d_window_t *w;
 
                     w = screen_find_window(sc, sev->affected_window);
-                    if (w) {
+                    if (w && window_is_mapped(w)) {
                         sc->window_reshape(w);
                         screen_refresh(w->sc);
                         break;
@@ -298,6 +301,8 @@ run(d_display_t *dpy)
 {
     struct timeval now, next_repaint;
 
+    running = TRUE;
+
     gettimeofday(&now, NULL);
     next_repaint = now;
 
@@ -306,6 +311,7 @@ run(d_display_t *dpy)
         int            r, npaint, ntime;
         d_list_it_t   *it;
         fd_set         fds;
+        gboolean due;
 
         event(dpy);
 
@@ -338,27 +344,31 @@ run(d_display_t *dpy)
             }
         }
 
-        if (!npaint && !ntime)
+        if (!npaint && !ntime) {
             /* wait forever, there is nothing that needs drawing */
             wait = NULL;
+            due = FALSE;
+        }
         else if (time_compare(&next, &now) > 0) {
             /* wait until the next allowed redraw time */
             time_difference(&next, &now, &next);
             wait = &next;
+            due = FALSE;
         }
         else {
             /* don't wait cuz a timer is due now already */
-            next.tv_sec = 0;
-            next.tv_usec = 1;
-            wait = &next;
+            due = TRUE;
         }
 
-        FD_ZERO(&fds);
-        FD_SET(dpy->fd, &fds);
-
-        //printf("select %d\n", npaint);
+        //printf("select? %d %d\n", due, npaint);
 
-        r = select(dpy->fd+1, &fds, NULL, NULL, wait);
+        if (!due) {
+            FD_ZERO(&fds);
+            FD_SET(dpy->fd, &fds);
+            r = select(dpy->fd+1, &fds, NULL, NULL, wait);
+        }
+        else
+            r = 0;
 
         gettimeofday(&now, NULL);
         if (r == 0) {
@@ -375,6 +385,8 @@ run(d_display_t *dpy)
         if (xcb_connection_has_error(dpy->conn))
             quit = TRUE;
     }
+
+    running = FALSE;
 }
 
 static void
@@ -475,6 +487,7 @@ main(int argc, char **argv)
         }
     }
 
+    printf("running\n");
     run(dpy);
 
     {
@@ -496,3 +509,9 @@ main(int argc, char **argv)
     display_unref(dpy);
     return 0;
 }
+
+gboolean
+dcompmgr_running(void)
+{
+    return running;
+}