diff options
author | Alon Levy <alevy@redhat.com> | 2012-06-20 23:29:54 +0300 |
---|---|---|
committer | Alon Levy <alevy@redhat.com> | 2012-06-24 09:38:25 +0300 |
commit | ec738648c35b13589e1d8255dc0467a9ac9cf52f (patch) | |
tree | e76f6b6baddb789f33156367a67a73252771f677 | |
parent | cb875724da7233ab407f63ddbb98b083147d9fe4 (diff) |
vdagent: add -y for sync X11 communication
-rw-r--r-- | src/vdagent-x11.c | 12 | ||||
-rw-r--r-- | src/vdagent-x11.h | 2 | ||||
-rw-r--r-- | src/vdagent.c | 8 |
3 files changed, 18 insertions, 4 deletions
diff --git a/src/vdagent-x11.c b/src/vdagent-x11.c index 38c4205..3af8e75 100644 --- a/src/vdagent-x11.c +++ b/src/vdagent-x11.c @@ -67,8 +67,13 @@ static const char *vdagent_x11_sel_to_str(uint8_t selection) { } } +static int debug_error_handler(Display *display, XErrorEvent *error) +{ + abort(); +} + struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd, - FILE *errfile, int verbose) + FILE *errfile, int verbose, int sync) { struct vdagent_x11 *x11; XWindowAttributes attrib; @@ -91,6 +96,11 @@ struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd, return NULL; } + if (sync) { + XSetErrorHandler(debug_error_handler); + XSynchronize(x11->display, True); + } + x11->screen = DefaultScreen(x11->display); x11->root_window = RootWindow(x11->display, x11->screen); x11->fd = ConnectionNumber(x11->display); diff --git a/src/vdagent-x11.h b/src/vdagent-x11.h index 800cbd0..f595cac 100644 --- a/src/vdagent-x11.h +++ b/src/vdagent-x11.h @@ -29,7 +29,7 @@ struct vdagent_x11; struct vdagent_x11 *vdagent_x11_create(struct udscs_connection *vdagentd, - FILE *errfile, int verbose); + FILE *errfile, int verbose, int sync); void vdagent_x11_destroy(struct vdagent_x11 *x11); int vdagent_x11_get_fd(struct vdagent_x11 *x11); diff --git a/src/vdagent.c b/src/vdagent.c index f475120..82c5ff9 100644 --- a/src/vdagent.c +++ b/src/vdagent.c @@ -155,11 +155,12 @@ int main(int argc, char *argv[]) fd_set readfds, writefds; int c, n, nfds, x11_fd, retval = 0; int do_daemonize = 1; + int x11_sync = 0; char *home, filename[1024]; struct sigaction act; for (;;) { - if (-1 == (c = getopt(argc, argv, "-dxhs:"))) + if (-1 == (c = getopt(argc, argv, "-dxhys:"))) break; switch (c) { case 'd': @@ -171,6 +172,9 @@ int main(int argc, char *argv[]) case 'x': do_daemonize = 0; break; + case 'y': + x11_sync = 1; + break; case 'h': usage(stdout); return 0; @@ -230,7 +234,7 @@ reconnect: goto finish; } - x11 = vdagent_x11_create(client, logfile, verbose); + x11 = vdagent_x11_create(client, logfile, verbose, x11_sync); if (!x11) { udscs_destroy_connection(&client); retval = 1; |