JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
convert a XConfigureWindow to XCB.
[spectrwm.git] / spectrwm.c
index 9e35632..0f6b131 100644 (file)
@@ -2305,7 +2305,9 @@ restart(struct swm_region *r, union arg *args)
        bar_extra_stop();
        bar_extra = 1;
        unmap_all();
-       XCloseDisplay(display);
+       xcb_flush(conn);
+       xcb_disconnect(conn);
+
        execvp(start_argv[0], start_argv);
        warn("execvp failed");
        quit(NULL, NULL);
@@ -6473,7 +6475,6 @@ manage_window(xcb_window_t id)
 
        /* Get all the window data in one shot */
        ws_idx_atom = get_atom_from_string("_SWM_WS");
-       fprintf(stderr, "ws_idx_atom: %d\n", ws_idx_atom);
        if (ws_idx_atom) {
                gpr = xcb_get_property_reply(conn,
                        xcb_get_property(conn, False, id, ws_idx_atom,
@@ -6834,28 +6835,49 @@ configurerequest(XEvent *e)
 {
        XConfigureRequestEvent  *ev = &e->xconfigurerequest;
        struct ws_win           *win;
-       int                     new = 0;
-       XWindowChanges          wc;
+       int                     new = 0, i = 0;
+       uint16_t                mask = 0;       
+       uint32_t                wc[7];
 
        if ((win = find_window(ev->window)) == NULL)
                if ((win = find_unmanaged_window(ev->window)) == NULL)
                        new = 1;
 
        if (new) {
-               bzero(&wc, sizeof wc);
-               wc.x = ev->x;
-               wc.y = ev->y;
-               wc.width = ev->width;
-               wc.height = ev->height;
-               wc.border_width = ev->border_width;
-               wc.sibling = ev->above;
-               wc.stack_mode = ev->detail;
+               if (ev->value_mask & XCB_CONFIG_WINDOW_X) {
+                       mask |= XCB_CONFIG_WINDOW_X;
+                       wc[i++] = ev->x;
+               }
+               if (ev->value_mask & XCB_CONFIG_WINDOW_Y) {
+                       mask |= XCB_CONFIG_WINDOW_Y;
+                       wc[i++] = ev->y;
+               }
+               if (ev->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
+                       mask |= XCB_CONFIG_WINDOW_WIDTH;
+                       wc[i++] = ev->width;
+               }
+               if (ev->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
+                       mask |= XCB_CONFIG_WINDOW_HEIGHT;
+                       wc[i++] = ev->height;
+               }
+               if (ev->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
+                       mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
+                       wc[i++] = ev->border_width;
+               }
+               if (ev->value_mask & XCB_CONFIG_WINDOW_SIBLING) {
+                       mask |= XCB_CONFIG_WINDOW_SIBLING;
+                       wc[i++] = ev->above;
+               }
+               if (ev->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
+                       mask |= XCB_CONFIG_WINDOW_STACK_MODE;
+                       wc[i++] = ev->detail;
+               }
 
                DNPRINTF(SWM_D_EVENT, "configurerequest: new window: 0x%lx, "
                    "new: %s, (x,y) w x h: (%d,%d) %d x %d\n", ev->window,
                    YESNO(new), wc.x, wc.y, wc.width, wc.height);
 
-               XConfigureWindow(display, ev->window, ev->value_mask, &wc);
+               xcb_configure_window(conn, ev->window, mask, wc);
        } else if ((!win->manual || win->quirks & SWM_Q_ANYWHERE) &&
            !(win->ewmh_flags & EWMH_F_FULLSCREEN)) {
                win->g_float.x = ev->x - X(win->ws->r);
@@ -7968,7 +7990,6 @@ done:
                        xcb_free_gc(conn, screens[i].bar_gc);
        XFreeFontSet(display, bar_fs);
        xcb_disconnect(conn);
-       XCloseDisplay(display);
 
        return (0);
 }