diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-09-02 19:50:17 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-09-02 19:50:17 +0100 |
commit | 5af9d69485a241156c343b67a741bc024e3f6edf (patch) | |
tree | 7d06c75b4d4ce18c4996c0321a343f780dc21c2c /tools | |
parent | 88d43dc2aea1ee4b8a3248bf442f5be362b32fbe (diff) |
intel-virtual-output: Reorder the fds
We can't place the record fd at after the displays as we may wish to
clone more displays later and use the simplification that they are in a
linear, contiguous block at the end of the fd array.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/virtual.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/tools/virtual.c b/tools/virtual.c index 39812bcf..1beccac4 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -2302,6 +2302,12 @@ int main(int argc, char **argv) XRRSelectInput(ctx.display->dpy, ctx.display->root, RRScreenChangeNotifyMask); XFixesSelectCursorInput(ctx.display->dpy, ctx.display->root, XFixesDisplayCursorNotifyMask); + ret = add_fd(&ctx, record_mouse(&ctx)); + if (ret) { + fprintf(stderr, "XTEST extension not supported by display \"%s\"\n", DisplayString(ctx.display->dpy)); + return -ret; + } + open = fail = 0; for (i = optind; i < argc; i++) { ret = last_display_clone(&ctx, display_open(&ctx, argv[i])); @@ -2332,12 +2338,6 @@ int main(int argc, char **argv) if (open == 0) return fail ? ECONNREFUSED : 0; - ret = add_fd(&ctx, record_mouse(&ctx)); - if (ret) { - fprintf(stderr, "XTEST extension not supported by display \"%s\"\n", DisplayString(ctx.display->dpy)); - return -ret; - } - if (daemonize && daemon(0, 0)) return EINVAL; @@ -2346,18 +2346,26 @@ int main(int argc, char **argv) XEvent e; int reconfigure = 0; + DBG(("polling - enable timer? %d, nfd=%d\n", enable_timer, ctx.nfd)); ret = poll(ctx.pfd + !enable_timer, ctx.nfd - !enable_timer, -1); if (ret <= 0) break; + /* pfd[0] is the timer, pfd[1] is the local display, pfd[2] is the mouse, pfd[3+] are the remotes */ + + DBG(("poll reports %d fd awake\n", ret)); if (ctx.pfd[1].revents) { int damaged = 0; + DBG(("%s woken up\n", DisplayString(ctx.display[0].dpy))); do { XNextEvent(ctx.display->dpy, &e); if (e.type == ctx.display->damage_event + XDamageNotify ) { const XDamageNotifyEvent *de = (const XDamageNotifyEvent *)&e; + DBG(("%s damaged: (%d, %d)x(%d, %d)\n", + DisplayString(ctx.display->dpy), + de->area.x, de->area.y, de->area.width, de->area.height)); for (i = 0; i < ctx.nclone; i++) clone_damage(&ctx.clones[i], &de->area); if (!enable_timer) @@ -2375,6 +2383,8 @@ int main(int argc, char **argv) XFree(cur); } else if (e.type == ctx.display->rr_event + RRScreenChangeNotify) { + DBG(("%s screen changed (reconfigure pending? %d)\n", + DisplayString(ctx.display->dpy), reconfigure)); reconfigure = 1; if (!enable_timer) enable_timer = read(ctx.timer, &count, sizeof(count)) > 0; @@ -2405,13 +2415,15 @@ int main(int argc, char **argv) } for (i = 1; ret && i < ctx.ndisplay; i++) { - if (ctx.pfd[i+1].revents == 0) + if (ctx.pfd[i+2].revents == 0) continue; + DBG(("%s woken up\n", DisplayString(ctx.display[i].dpy))); do { XNextEvent(ctx.display[i].dpy, &e); - if (ctx.display[i].rr_event && e.type == ctx.display[i].rr_event + RRNotify) { + DBG(("%s received event %d\n", DisplayString(ctx.display[i].dpy), e.type)); + if (ctx.display[i].rr_active && e.type == ctx.display[i].rr_event + RRNotify) { XRRNotifyEvent *re = (XRRNotifyEvent *)&e; if (re->subtype == RRNotify_OutputChange) { XRROutputPropertyNotifyEvent *ro = (XRROutputPropertyNotifyEvent *)re; @@ -2424,7 +2436,7 @@ int main(int argc, char **argv) } } } - } while (XPending(ctx.display[i].dpy) || poll(&ctx.pfd[i+1], 1, 0) > 0); + } while (XPending(ctx.display[i].dpy) || poll(&ctx.pfd[i+2], 1, 0) > 0); ret--; } |