void client_resize(Client* client, XRectangle rect) { Monitor* m; if (client->fullscreen && (m = find_monitor_with_tag(client->tag))) { XSetWindowBorderWidth(gDisplay, client->window, 0); client->last_size = m->rect; XMoveResizeWindow(gDisplay, client->window, m->rect.x, m->rect.y, m->rect.width, m->rect.height); } else if (!client->floating) { // apply border width rect.width -= (window_border_width*2); rect.height -= (window_border_width*2); // ensure minimum size if (rect.width < WIN_MIN_WIDTH) rect.width = WIN_MIN_WIDTH; if (rect.height < WIN_MIN_HEIGHT) rect.height = WIN_MIN_HEIGHT; if (!client) return; Window win = client->window; if (client) { if (RECTANGLE_EQUALS(client->last_size, rect)) return; client->last_size = rect; } XSetWindowBorderWidth(gDisplay, win, window_border_width); XMoveResizeWindow(gDisplay, win, rect.x, rect.y, rect.width, rect.height); } }
void client_resize(HSClient* client, XRectangle rect, HSFrame* frame) { // ensure minimum size if (rect.width < WINDOW_MIN_WIDTH) { rect.width = WINDOW_MIN_WIDTH; } if (rect.height < WINDOW_MIN_HEIGHT) { rect.height = WINDOW_MIN_HEIGHT; } if (!client) { HSDebug("Warning: client_resize(NULL, ...) was called\n"); return; } Window win = client->window; if (client->pseudotile) { XRectangle size = client->float_size; // floating sizes don't include window border, tiling sizes do. // so convert the floating size to a tiling size size.width += *g_window_border_width * 2; size.height += *g_window_border_width * 2; // ensure size is not larger than rect-tile size.width = MIN(size.width, rect.width); size.height = MIN(size.height, rect.height); // center it rect.x = rect.x + rect.width/2 - size.width/2; rect.y = rect.y + rect.height/2 - size.height/2; rect.width = size.width; rect.height = size.height; } int border_width = *g_window_border_width; if (*g_smart_window_surroundings && !client->pseudotile && (frame->content.clients.count == 1 || frame->content.clients.layout == LAYOUT_MAX)) { border_width = 0; } if (RECTANGLE_EQUALS(client->last_size, rect) && client->last_border_width == border_width) { return; } client->last_size = rect; client->last_border_width = border_width; // apply border width rect.width -= border_width * 2; rect.height -= border_width * 2; if (!*g_smart_window_surroundings || (frame->content.clients.count != 1 && frame->content.clients.layout != LAYOUT_MAX)) { // apply window gap rect.width -= *g_window_gap; rect.height -= *g_window_gap; } XSetWindowBorderWidth(g_display, win, border_width); XMoveResizeWindow(g_display, win, rect.x, rect.y, rect.width, rect.height); if (*g_window_border_inner_width > 0 && *g_window_border_inner_width < *g_window_border_width) { unsigned long current_border_color = get_window_border_color(client); HSDebug("client_resize %s\n", current_border_color == g_window_border_active_color ? "ACTIVE" : "NORMAL"); set_window_double_border(g_display, win, *g_window_border_inner_width, g_window_border_inner_color, current_border_color); } //// send new size to client //// WHY SHOULD I? -> faster? only one call? //XConfigureEvent ce; //ce.type = ConfigureNotify; //ce.display = g_display; //ce.event = win; //ce.window = win; //ce.x = rect.x; //ce.y = rect.y; //ce.width = rect.width; //ce.height = rect.height; //ce.border_width = 0; //ce.above = None; //ce.override_redirect = False; //XSendEvent(g_display, win, False, StructureNotifyMask, (XEvent *)&ce); }