From: Mikko Rasa Date: Fri, 11 Dec 2015 16:35:20 +0000 (+0200) Subject: Ignore errors from the X server X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f8e05a9f3004b5d6cb135512785283e003f0c16e;p=geometrycompositor.git Ignore errors from the X server Events don't provide enough information to perform all necessary operations atomically, so some errors are unavoidable. --- diff --git a/source/main.c b/source/main.c index 561159d..ae9bc4f 100644 --- a/source/main.c +++ b/source/main.c @@ -87,6 +87,13 @@ static const float vertices[] = 1.0f, 0.0f }; +int x_error_handler(Display *display, XErrorEvent *event) +{ + printf("Ignoring X error %d on resource %lx\n", event->error_code, event->resourceid); + (void)display; + return 0; +} + int with_error(const char *message) { fprintf(stderr, "%s\n", message); @@ -258,7 +265,11 @@ void add_window(Compositor *compositor, CompositedScreen *screen, Window w) if(w==screen->root || w==screen->overlay) return; - XGetWindowAttributes(compositor->display, w, &win_attr); + if(!XGetWindowAttributes(compositor->display, w, &win_attr)) + { + printf("XGetWindowAttributes failed; probably the window was already destroyed\n"); + return; + } if(win_attr.class==InputOnly) return; @@ -379,6 +390,8 @@ int initialize_compositor(Compositor *compositor) if(!compositor->display) return with_error("Could not open X display"); + XSetErrorHandler(&x_error_handler); + if(!XCompositeQueryExtension(compositor->display, &event_base, &error_base)) return with_error("XComposite is required but was not found"); else if(!XCompositeQueryVersion(compositor->display, &major_ver, &minor_ver))