From 3e65f190e8a33169b20d8d3a011235d65ef0b9d3 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 10 Feb 2017 15:15:47 +0000 Subject: 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 --- overlay/x11/x11-overlay.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'overlay') 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); -- cgit v1.2.3