- xcb_configure_request_event_t *e = (xcb_configure_request_event_t *) evt;
-
- PRINTF("configure request %X\n", e->window);
-
- window_location_t loc;
- bool is_managed = locate_window(e->window, &loc);
-
- if (!is_managed || is_floating(loc.node->client)) {
- uint16_t mask = 0;
- uint32_t values[7];
- unsigned short i = 0;
-
- if (e->value_mask & XCB_CONFIG_WINDOW_X) {
- mask |= XCB_CONFIG_WINDOW_X;
- values[i++] = e->x;
- if (is_managed)
- loc.node->client->floating_rectangle.x = e->x;
- }
-
- if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
- mask |= XCB_CONFIG_WINDOW_Y;
- values[i++] = e->y;
- if (is_managed)
- loc.node->client->floating_rectangle.y = e->y;
- }
-
- if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
- mask |= XCB_CONFIG_WINDOW_WIDTH;
- values[i++] = e->width;
- if (is_managed)
- loc.node->client->floating_rectangle.width = e->width;
- }
-
- if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
- mask |= XCB_CONFIG_WINDOW_HEIGHT;
- values[i++] = e->height;
- if (is_managed)
- loc.node->client->floating_rectangle.height = e->height;
- }
-
- if (!is_managed && e->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
- mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
- values[i++] = e->border_width;
- }
-
- if (e->value_mask & XCB_CONFIG_WINDOW_SIBLING) {
- mask |= XCB_CONFIG_WINDOW_SIBLING;
- values[i++] = e->sibling;
- }
-
- if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
- mask |= XCB_CONFIG_WINDOW_STACK_MODE;
- values[i++] = e->stack_mode;
- }
-
- xcb_configure_window(dpy, e->window, mask, values);
- if (is_managed)
- window_draw_border(loc.node, loc.node == loc.desktop->focus, loc.monitor == mon);
- } else {
- xcb_configure_notify_event_t evt;
- xcb_rectangle_t rect;
- unsigned int bw;
- xcb_window_t win = loc.node->client->window;
-
- if (is_tiled(loc.node->client)) {
- rect = loc.node->client->tiled_rectangle;
- bw = border_width;
- } else {
- rect = (xcb_rectangle_t) {0, 0, screen_width, screen_height};
- bw = 0;
- }
-
- evt.response_type = XCB_CONFIGURE_NOTIFY;
- evt.event = win;
- evt.window = win;
- evt.above_sibling = XCB_NONE;
- evt.x = rect.x;
- evt.y = rect.y;
- evt.width = rect.width;
- evt.height = rect.height;
- evt.border_width = bw;
- evt.override_redirect = false;
-
- xcb_send_event(dpy, false, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char *) &evt);
- }
+ xcb_configure_request_event_t *e = (xcb_configure_request_event_t *) evt;
+
+ PRINTF("configure request %X\n", e->window);
+
+ coordinates_t loc;
+ bool is_managed = locate_window(e->window, &loc);
+ client_t *c = (is_managed ? loc.node->client : NULL);
+ int w = 0, h = 0;
+
+ if (is_managed && !is_floating(c)) {
+ if (e->value_mask & XCB_CONFIG_WINDOW_X)
+ c->floating_rectangle.x = e->x;
+ if (e->value_mask & XCB_CONFIG_WINDOW_Y)
+ c->floating_rectangle.y = e->y;
+ if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH)
+ w = e->width;
+ if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT)
+ h = e->height;
+
+ if (w != 0) {
+ restrain_floating_width(c, &w);
+ c->floating_rectangle.width = w;
+ }
+
+ if (h != 0) {
+ restrain_floating_height(c, &h);
+ c->floating_rectangle.height = h;
+ }
+
+ xcb_configure_notify_event_t evt;
+ xcb_rectangle_t rect;
+ xcb_window_t win = c->window;
+ unsigned int bw = c->border_width;
+
+ if (c->fullscreen)
+ rect = loc.monitor->rectangle;
+ else
+ rect = c->tiled_rectangle;
+
+ evt.response_type = XCB_CONFIGURE_NOTIFY;
+ evt.event = win;
+ evt.window = win;
+ evt.above_sibling = XCB_NONE;
+ evt.x = rect.x;
+ evt.y = rect.y;
+ evt.width = rect.width;
+ evt.height = rect.height;
+ evt.border_width = bw;
+ evt.override_redirect = false;
+
+ xcb_send_event(dpy, false, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char *) &evt);
+
+ if (c->pseudo_tiled)
+ arrange(loc.monitor, loc.desktop);
+ } else {
+ uint16_t mask = 0;
+ uint32_t values[7];
+ unsigned short i = 0;
+
+ if (e->value_mask & XCB_CONFIG_WINDOW_X) {
+ mask |= XCB_CONFIG_WINDOW_X;
+ values[i++] = e->x;
+ if (is_managed)
+ c->floating_rectangle.x = e->x;
+ }
+
+ if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
+ mask |= XCB_CONFIG_WINDOW_Y;
+ values[i++] = e->y;
+ if (is_managed)
+ c->floating_rectangle.y = e->y;
+ }
+
+ if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
+ mask |= XCB_CONFIG_WINDOW_WIDTH;
+ w = e->width;
+ if (is_managed) {
+ restrain_floating_width(c, &w);
+ c->floating_rectangle.width = w;
+ }
+ values[i++] = w;
+ }
+
+ if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
+ mask |= XCB_CONFIG_WINDOW_HEIGHT;
+ h = e->height;
+ if (is_managed) {
+ restrain_floating_height(c, &h);
+ c->floating_rectangle.height = h;
+ }
+ values[i++] = h;
+ }
+
+ if (!is_managed && e->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
+ mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
+ values[i++] = e->border_width;
+ }
+
+ if (e->value_mask & XCB_CONFIG_WINDOW_SIBLING) {
+ mask |= XCB_CONFIG_WINDOW_SIBLING;
+ values[i++] = e->sibling;
+ }
+
+ if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
+ mask |= XCB_CONFIG_WINDOW_STACK_MODE;
+ values[i++] = e->stack_mode;
+ }
+
+ xcb_configure_window(dpy, e->window, mask, values);
+ }
+
+ if (is_managed)
+ translate_client(monitor_from_client(c), loc.monitor, c);