From 47b7e334c1c66f4649b09e08bd93fb112399d1d0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 31 Aug 2013 22:39:18 +0100 Subject: intel-virtual-output: Try to hide races with gnome-shell As we try to create VirtualHeads, gnome-shell tries to enable them. Leading to a lot of flashing and extraneous modes appearing. Without being able to grab the screen configuration for the duration of our pruning, there does not seem much we can do other than try and squelch the worst of the errors. Signed-off-by: Chris Wilson --- tools/virtual.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/virtual.c b/tools/virtual.c index d38c55e1..30bab7b7 100644 --- a/tools/virtual.c +++ b/tools/virtual.c @@ -387,6 +387,10 @@ static RROutput claim_virtual(struct display *display, const char *name) rr_output = res->outputs[i]; XRRFreeOutputInfo(o); } + for (i = id = 0; id == 0 && i < res->nmode; i++) { + if (strcmp(res->modes[i].name, buf) == 0) + id = res->modes[i].id; + } XRRFreeScreenResources(res); DBG(("%s(%s): rr_output=%ld\n", __func__, name, (long)rr_output)); @@ -400,7 +404,8 @@ static RROutput claim_virtual(struct display *display, const char *name) mode.name = buf; mode.nameLength = sizeof(buf) - 1; - id = XRRCreateMode(dpy, display->root, &mode); + if (id == 0) + id = XRRCreateMode(dpy, display->root, &mode); XRRAddOutputMode(dpy, rr_output, id); /* Force a redetection for the ddx to spot the new outputs */ @@ -1492,8 +1497,8 @@ static int last_display_add_clones(struct context *ctx) sprintf(buf, "VIRTUAL%d", ctx->nclone); ret = clone_output_init(clone, &clone->src, ctx->display, buf, claim_virtual(ctx->display, buf)); if (ret) { - fprintf(stderr, "Failed to find available VirtualHead for \"%s\" on display \"%s\"\n", - o->name, DisplayString(display->dpy)); + fprintf(stderr, "Failed to find available VirtualHead \"%s\" for \"%s\" on display \"%s\"\n", + buf, o->name, DisplayString(display->dpy)); return ret; } @@ -1540,6 +1545,7 @@ static void display_flush(struct display *display) int main(int argc, char **argv) { struct context ctx; + int (*old_handler)(Display *display, XErrorEvent *event); const char *src_name = NULL; uint64_t count; int enable_timer = 0; @@ -1578,6 +1584,9 @@ int main(int argc, char **argv) XRRSelectInput(ctx.display->dpy, ctx.display->root, RRScreenChangeNotifyMask); XFixesSelectCursorInput(ctx.display->dpy, ctx.display->root, XFixesDisplayCursorNotifyMask); + XSync(ctx.display->dpy, False); + old_handler = XSetErrorHandler(_check_error_handler); + if (optind == argc || bumblebee) { ret = add_fd(&ctx, bumblebee_open(&ctx)); if (ret) { @@ -1603,6 +1612,9 @@ int main(int argc, char **argv) return -ret; } + XSync(ctx.display->dpy, False); + XSetErrorHandler(old_handler); + ret = add_fd(&ctx, record_mouse(&ctx)); if (ret) { fprintf(stderr, "XTEST extension not supported by display \"%s\"\n", DisplayString(ctx.display[0].dpy)); -- cgit v1.2.3