JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
go back to using XPending() for now.
[spectrwm.git] / spectrwm.c
index 1f88aa2..382b825 100644 (file)
@@ -637,6 +637,7 @@ map_window_raised(xcb_window_t win)
                XCB_CONFIG_WINDOW_STACK_MODE, &val);
 
        xcb_map_window(conn, win);      
+       xcb_flush(conn);
 }
 
 xcb_atom_t
@@ -6287,7 +6288,8 @@ manage_window(xcb_window_t id)
        const char              *errstr;
        struct pid_e            *p;
        struct quirk            *qp;
-
+       uint32_t                event_mask;
+       
        if ((win = find_window(id)) != NULL)
                return (win);   /* already being managed */
 
@@ -6506,9 +6508,12 @@ manage_window(xcb_window_t id)
                update_window(win);
        }
 
-       XSelectInput(display, id, EnterWindowMask | FocusChangeMask |
-           PropertyChangeMask | StructureNotifyMask);
+       event_mask = XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_FOCUS_CHANGE |
+                       XCB_EVENT_MASK_PROPERTY_CHANGE |
+                       XCB_EVENT_MASK_STRUCTURE_NOTIFY;
 
+       xcb_change_window_attributes(conn, id, XCB_CW_EVENT_MASK, &event_mask);
+       
        /* floaters need to be mapped if they are in the current workspace */
        if ((win->floating || win->transient) && (ws->idx == r->ws->idx))
                map_window_raised(win->id);
@@ -7421,10 +7426,9 @@ void
 setup_screens(void)
 {
        int                     i, j, k, num_screens;
-       int                     errorbase;
        struct workspace        *ws;
        XGCValues               gcv;
-
+       const xcb_query_extension_reply_t *qep;
        xcb_randr_query_version_cookie_t        c;
        xcb_randr_query_version_reply_t         *r;
 
@@ -7435,18 +7439,16 @@ setup_screens(void)
                    "screens");
 
        /* initial Xrandr setup */
-       xrandr_support = XRRQueryExtension(display,
-           &xrandr_eventbase, &errorbase);
-       if (xrandr_support) {
-               c = xcb_randr_query_version(conn, True, False);
-               r = xcb_randr_query_version_reply(conn, c, NULL);
-               if (r) {
-                       if (r->major_version < 1)
-                               xrandr_support = 0;
-                       free(r);
-               } else
-                       xrandr_support = 0;
+       xrandr_support = False;
+       c = xcb_randr_query_version(conn, True, True);
+       r = xcb_randr_query_version_reply(conn, c, NULL);
+       if (r) {
+               if (r->major_version >= 1)
+                       xrandr_support = True;
+               free(r);
        }
+       qep = xcb_get_extension_data(conn, &xcb_randr_id);
+       xrandr_eventbase = qep->first_event;
 
        /* map physical screens */
        for (i = 0; i < num_screens; i++) {
@@ -7551,7 +7553,6 @@ main(int argc, char *argv[])
        int                     xfd, i, num_screens;
        fd_set                  rd;
        struct sigaction        sact;
-       xcb_generic_event_t     *evt;
        
        start_argv = argv;
        warnx("Welcome to spectrwm V%s Build: %s", SPECTRWM_VERSION, buildstr);
@@ -7673,7 +7674,7 @@ noconfig:
 
        xfd = xcb_get_file_descriptor(conn); 
        while (running) {
-               while ((evt = xcb_poll_for_event(conn)) == 0) {
+               while (XPending(display)) {
                        XNextEvent(display, &e);
                        if (running == 0)
                                goto done;