JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
convert bar_urgent to XCB
[spectrwm.git] / spectrwm.c
index 3367c2a..1f88aa2 100644 (file)
@@ -1502,10 +1502,11 @@ int             urgent[SWM_WS_MAX];
 void
 bar_urgent(char *s, size_t sz)
 {
-       XWMHints                *wmh = NULL;
        struct ws_win           *win;
        int                     i, j, num_screens;
        char                    b[8];
+       xcb_get_property_cookie_t       c;
+       xcb_wm_hints_t          hints;
 
        for (i = 0; i < workspace_limit; i++)
                urgent[i] = 0;
@@ -1514,13 +1515,12 @@ bar_urgent(char *s, size_t sz)
        for (i = 0; i < num_screens; i++)
                for (j = 0; j < workspace_limit; j++)
                        TAILQ_FOREACH(win, &screens[i].ws[j].winlist, entry) {
-                               wmh = XGetWMHints(display, win->id);
-                               if (wmh == NULL)
+                               c = xcb_get_wm_hints(conn, win->id);
+                               if (xcb_get_wm_hints_reply(conn, c,
+                                               &hints, NULL) == 0)
                                        continue;
-
-                               if (wmh->flags & XUrgencyHint)
+                               if (hints.flags & XCB_WM_HINT_X_URGENCY)
                                        urgent[j] = 1;
-                               XFree(wmh);
                        }
 
        for (i = 0; i < workspace_limit; i++) {
@@ -3223,6 +3223,7 @@ adjust_font(struct ws_win *win)
 void
 stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
 {
+       XWindowAttributes       wa;
        struct swm_geometry     win_g, r_g = *g;
        struct ws_win           *win, *fs_win = NULL;
        int                     i, j, s, stacks;
@@ -3231,8 +3232,6 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
        int                     split, colno, winno, mwin, msize, mscale;
        int                     remain, missing, v_slice, reconfigure;
        int                     bordered = 1;
-       xcb_get_window_attributes_cookie_t      wac;
-       xcb_get_window_attributes_reply_t       *war;
 
        DNPRINTF(SWM_D_STACK, "stack_master: workspace: %d, rot: %s, "
            "flip: %s\n", ws->idx, YESNO(rot), YESNO(flip));
@@ -3395,13 +3394,10 @@ stack_master(struct workspace *ws, struct swm_geometry *g, int rot, int flip)
                        update_window(win);
                }
 
-               wac = xcb_get_window_attributes(conn, win->id);
-               war = xcb_get_window_attributes_reply(conn, wac, NULL);
-               if (war) {
-                       if (war->map_state == XCB_MAP_STATE_UNMAPPED)
+               if (XGetWindowAttributes(display, win->id, &wa))
+                       if (wa.map_state == IsUnmapped)
                                map_window_raised(win->id);
-                       free(war);
-               }
+
                last_h = win_g.h;
                i++;
                j++;