window: Run deferred tasks before blocking for initial iteration
authorKristian Høgsberg <krh@bitplanet.net>
Mon, 9 Jan 2012 23:48:14 +0000 (18:48 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Mon, 9 Jan 2012 23:48:14 +0000 (18:48 -0500)
The first iteration of the while loop wouldn't run the deferred tasks
before blocking in epoll_wait().  Move things around so we do.

clients/window.c

index 7ca1e1d..4da418d 100644 (file)
@@ -2998,26 +2998,26 @@ display_run(struct display *display)
 
        display->running = 1;
        while (1) {
-               while (display->mask & WL_DISPLAY_WRITABLE)
-                       wl_display_iterate(display->display,
-                                          WL_DISPLAY_WRITABLE);
+               wl_display_flush(display->display);
+
+               while (!wl_list_empty(&display->deferred_list)) {
+                       task = container_of(display->deferred_list.next,
+                                           struct task, link);
+                       wl_list_remove(&task->link);
+                       task->run(task, 0);
+               }
 
                if (!display->running)
                        break;
 
+               wl_display_flush(display->display);
+
                count = epoll_wait(display->epoll_fd,
                                   ep, ARRAY_LENGTH(ep), -1);
                for (i = 0; i < count; i++) {
                        task = ep[i].data.ptr;
                        task->run(task, ep[i].events);
                }
-
-               while (!wl_list_empty(&display->deferred_list)) {
-                       task = container_of(display->deferred_list.next,
-                                           struct task, link);
-                       wl_list_remove(&task->link);
-                       task->run(task, 0);
-               }
        }
 }