diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-11-30 23:40:14 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-11-30 23:54:05 +0000 |
commit | cdd06717643f4d110a0d9c2b72851f9cb2c64b81 (patch) | |
tree | 70b7cf7bc89d37e6464a1708e945793e52f10b9b /tools | |
parent | bde946054efbc1c7ae1483b84c3b4fa3c2c7e2ec (diff) |
tools/intel-virtual-output: Check for pending events before blocking
If the xlib/xcb library has pulled events from the fd, then a poll on
that fd will block until new events arrive. If none do, we fail to
process the currently waiting events in a timely fashion.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/virtual.c | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/tools/virtual.c b/tools/virtual.c index 77e6a586..fc8db2b9 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -3392,6 +3392,7 @@ int main(int argc, char **argv) uint64_t count; int daemonize = 1, bumblebee = 0, siblings = 0, singleton = 1; int i, ret, open, fail; + int idle; signal(SIGPIPE, SIG_IGN); @@ -3572,21 +3573,30 @@ int main(int argc, char **argv) ctx.command_continuation = 0; update_cursor_image(&ctx); + + idle = 0; while (!done) { XEvent e; int reconfigure = 0; int rr_update = 0; - DBG(POLL, ("polling - enable timer? %d, nfd=%d, ndisplay=%d\n", ctx.timer_active, ctx.nfd, ctx.ndisplay)); - ret = poll(ctx.pfd + !ctx.timer_active, ctx.nfd - !ctx.timer_active, -1); - if (ret <= 0) - break; + if (idle) { + DBG(POLL, ("polling - enable timer? %d, nfd=%d, ndisplay=%d\n", ctx.timer_active, ctx.nfd, ctx.ndisplay)); + ret = poll(ctx.pfd + !ctx.timer_active, ctx.nfd - !ctx.timer_active, -1); + if (ret <= 0) + break; + + DBG(POLL, ("poll reports %d fd awake\n", ret)); + } + idle = 1; /* pfd[0] is the timer, pfd[1] is the local display, pfd[2] is the mouse, pfd[3+] are the remotes */ - DBG(POLL, ("poll reports %d fd awake\n", ret)); if (ctx.pfd[1].revents || XPending(ctx.display[0].dpy)) { DBG(POLL,("%s woken up\n", DisplayString(ctx.display[0].dpy))); + ctx.pfd[1].revents = 0; + idle = 0; + do { XNextEvent(ctx.display->dpy, &e); @@ -3663,6 +3673,9 @@ int main(int argc, char **argv) if (ctx.pfd[i+2].revents == 0 && !XPending(ctx.display[i].dpy)) continue; + ctx.pfd[i+2].revents = 0; + idle = 0; + DBG(POLL, ("%s woken up\n", DisplayString(ctx.display[i].dpy))); do { XNextEvent(ctx.display[i].dpy, &e); @@ -3742,6 +3755,7 @@ int main(int argc, char **argv) DBG(TIMER, ("%s timer still active? %d\n", DisplayString(ctx.display->dpy), ret != 0)); ctx.timer_active = ret != 0; + idle = 0; } } |