Index: tools/viewer/sk_app/unix/main_unix.cpp |
diff --git a/tools/viewer/sk_app/unix/main_unix.cpp b/tools/viewer/sk_app/unix/main_unix.cpp |
index 5e6b7fe3ee475b5e5201ace000e725b525c2f64b..c0fd4182622bc7f9fce49ec0f0780c14aebf4188 100644 |
--- a/tools/viewer/sk_app/unix/main_unix.cpp |
+++ b/tools/viewer/sk_app/unix/main_unix.cpp |
@@ -26,12 +26,13 @@ int main(int argc, char**argv) { |
// Get the file descriptor for the X display |
int x11_fd = ConnectionNumber(display); |
- fd_set in_fds; |
+ int count = x11_fd + 1; |
SkTHashSet<sk_app::Window_unix*> pendingWindows; |
bool done = false; |
while (!done) { |
// Create a file description set containing x11_fd |
+ fd_set in_fds; |
FD_ZERO(&in_fds); |
FD_SET(x11_fd, &in_fds); |
@@ -40,12 +41,15 @@ int main(int argc, char**argv) { |
tv.tv_usec = 100; |
tv.tv_sec = 0; |
- // Wait for an event on the file descriptor or for timer expiration |
- (void) select(1, &in_fds, NULL, NULL, &tv); |
+ while (!XPending(display)) { |
+ // Wait for an event on the file descriptor or for timer expiration |
+ (void) select(count, &in_fds, NULL, NULL, &tv); |
+ } |
// Handle XEvents (if any) and flush the input |
- XEvent event; |
- while (XPending(display) && !done) { |
+ int count = XPending(display); |
+ while (count-- && !done) { |
+ XEvent event; |
XNextEvent(display, &event); |
sk_app::Window_unix* win = sk_app::Window_unix::gWindowMap.find(event.xany.window); |
@@ -73,6 +77,8 @@ int main(int argc, char**argv) { |
app->onIdle(); |
} |
pendingWindows.reset(); |
+ |
+ XFlush(display); |
} |
delete app; |