]> git.tdb.fi Git - geometrycompositor.git/commitdiff
Ignore errors from the X server
authorMikko Rasa <tdb@tdb.fi>
Fri, 11 Dec 2015 16:35:20 +0000 (18:35 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 11 Dec 2015 16:35:20 +0000 (18:35 +0200)
Events don't provide enough information to perform all necessary
operations atomically, so some errors are unavoidable.

source/main.c

index 561159d5be08ebf6802a102049846b0f470d138f..ae9bc4ffabb629c9c1746e98925cfb5f5c55b4fe 100644 (file)
@@ -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))