JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
redo checking for an active wm with xcb
authorDavid Hill <dhill@conformal.com>
Sun, 15 Jul 2012 18:23:26 +0000 (14:23 -0400)
committerReginald Kennedy <rk@rejii.com>
Fri, 20 Jul 2012 21:59:30 +0000 (05:59 +0800)
spectrwm.c

index 54a3870..4b98919 100644 (file)
@@ -7098,22 +7098,20 @@ xerror(Display *d, XErrorEvent *ee)
        return (-1);
 }
 
-int
+void
 active_wm(void)
 {
-       other_wm = 0;
-       xerrorxlib = XSetErrorHandler(xerror_start);
+       int                     num_screens, i;
+       const uint32_t          val = XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT;     
+       xcb_screen_t            *sc;
 
        /* this causes an error if some other window manager is running */
-       XSelectInput(display, DefaultRootWindow(display),
-           SubstructureRedirectMask);
-       do_sync();
-       if (other_wm)
-               return (1);
-
-       XSetErrorHandler(xerror);
-       do_sync();
-       return (0);
+       num_screens = xcb_setup_roots_length(xcb_get_setup(conn));
+       for (i = 0; i < num_screens; i++) {
+               sc = get_screen(i);
+               xcb_change_window_attributes(conn, sc->root,
+                       XCB_CW_EVENT_MASK, &val);
+       }
 }
 
 void
@@ -7641,11 +7639,12 @@ main(int argc, char *argv[])
                free(evt);
        }
 
-       if (active_wm())
-               errx(1, "other wm running");
-
+       active_wm();
        xcb_aux_sync(conn);
 
+       if (xcb_poll_for_event(conn) != NULL)
+               errx(1, "another window manager is currently running");
+
        setup_globals();
        setup_screens();
        setup_keys();