Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: tools/viewer/sk_app/unix/main_unix.cpp

Issue 2226413002: Clean up Xlib viewer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix non-vulkan build Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/viewer/sk_app/VulkanWindowContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « tools/viewer/sk_app/VulkanWindowContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698