summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-02-10 15:15:47 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-02-10 15:16:23 +0000
commit3e65f190e8a33169b20d8d3a011235d65ef0b9d3 (patch)
tree8f1c2e70cc5f3236fba6cc00df98dd456a5e0fef
parentae7804ddb4cad7f15e26a0eccff7cc05bf080436 (diff)
overlay: Check for DRI2 errors when setting up
Otherwise we ignore a remote ssh connection and try to use DRI2 over it. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--overlay/x11/x11-overlay.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/overlay/x11/x11-overlay.c b/overlay/x11/x11-overlay.c
index 38d58b07..d08ebfc9 100644
--- a/overlay/x11/x11-overlay.c
+++ b/overlay/x11/x11-overlay.c
@@ -111,6 +111,14 @@ static void x11_overlay_destroy(void *data)
free(priv);
}
+static int x_error_count;
+
+static int check_error_handler(Display *display, XErrorEvent *event)
+{
+ x_error_count++;
+ return False; /* ignored */
+}
+
cairo_surface_t *
x11_overlay_create(struct config *config, int *width, int *height)
{
@@ -133,6 +141,8 @@ x11_overlay_create(struct config *config, int *width, int *height)
if (dpy == NULL)
return NULL;
+ XSetErrorHandler(check_error_handler);
+
scr = ScreenOfDisplay(dpy, DefaultScreen(dpy));
fd = dri2_open(dpy);
@@ -164,6 +174,9 @@ x11_overlay_create(struct config *config, int *width, int *height)
if (port == -1)
goto err_fd;
+ if (x_error_count)
+ goto err_fd;
+
XSetErrorHandler(noop);
position = x11_position(dpy, *width, *height, config, &x, &y, &w, &h);