static gboolean do_grow_all_edges(ObActionsData* data, ObClientDirectionalResizeType resize_type) { gint x, y, w, h; gint temp_x, temp_y, temp_w, temp_h; client_find_resize_directional(data->client, OB_DIRECTION_NORTH, resize_type, &temp_x, &temp_y, &temp_w, &temp_h); y = temp_y; h = temp_h; client_find_resize_directional(data->client, OB_DIRECTION_SOUTH, resize_type, &temp_x, &temp_y, &temp_w, &temp_h); h += temp_h - data->client->area.height; client_find_resize_directional(data->client, OB_DIRECTION_WEST, resize_type, &temp_x, &temp_y, &temp_w, &temp_h); x = temp_x; w = temp_w; client_find_resize_directional(data->client, OB_DIRECTION_EAST, resize_type, &temp_x, &temp_y, &temp_w, &temp_h); w += temp_w - data->client->area.width; /* When filling, we allow the window to move to an arbitrary x/y position, since we'll be growing the other edge as well. */ int lw, lh; client_try_configure(data->client, &x, &y, &w, &h, &lw, &lh, TRUE); if (x == data->client->area.x && y == data->client->area.y && w == data->client->area.width && h == data->client->area.height) { return FALSE; } actions_client_move(data, TRUE); client_move_resize(data->client, x, y, w, h); actions_client_move(data, FALSE); return TRUE; }
void handler_motionnotify_resize(struct client *c, XMotionEvent *ev) { int w, h; if (ISTILED(c)) { /* TODO: handle resizing of tiled clients */ } else if (ISRESIZABLE(c)) { w = ev->x_root + motion->attr.width - motion->start.x_root; h = ev->y_root + motion->attr.height - motion->start.y_root; client_move_resize(c, c->x, c->y, w, h, true, true); monitor_draw_bar(selmon); } }
void create_client(Window win, XWindowAttributes *attr) { struct client *c, *tc; c = client_create(win, attr); tc = find_client_by_trans(mons, win); client_setup(c, selmon, mons, tc); rules_apply(c); client_map_window(c); client_move_resize(c, c->x, c->y, c->w, c->h, true, true); monitor_add_client(c->mon, c); }
/* Always return FALSE because its not interactive */ static gboolean run_func(ObActionsData *data, gpointer options) { Options *o = options; if (data->client) { ObClient *c = data->client; gint x, y, ow, xoff, nw, oh, yoff, nh, lw, lh, wshrink, hshrink; gint left = o->left, right = o->right, top = o->top, bottom = o->bottom; if (o->left_denom) left = left * c->area.width / o->left_denom; if (o->right_denom) right = right * c->area.width / o->right_denom; if (o->top_denom) top = top * c->area.height / o->top_denom; if (o->bottom_denom) bottom = bottom * c->area.height / o->bottom_denom; // When resizing, if the resize has a non-zero value then make sure it // is at least as big as the size increment so the window does actually // resize. x = c->area.x; y = c->area.y; ow = c->area.width; xoff = -MAX(left, (left ? c->size_inc.width : 0)); wshrink = right + left < 0 ? -1 : 1; nw = ow + wshrink * MAX(abs(right + left), (abs(right + left) ? c->size_inc.width : 0)); oh = c->area.height; yoff = -MAX(top, (top ? c->size_inc.height : 0)); hshrink = bottom + top < 0 ? -1 : 1; nh = oh + hshrink * MAX(abs(bottom + top), (bottom + top ? c->size_inc.height : 0)); client_try_configure(c, &x, &y, &nw, &nh, &lw, &lh, TRUE); xoff = xoff == 0 ? 0 : (xoff < 0 ? MAX(xoff, ow-nw) : MIN(xoff, ow-nw)); yoff = yoff == 0 ? 0 : (yoff < 0 ? MAX(yoff, oh-nh) : MAX(yoff, oh-nh)); actions_client_move(data, TRUE); client_move_resize(c, x + xoff, y + yoff, nw, nh); actions_client_move(data, FALSE); } return FALSE; }
void handler_motionnotify_move(struct client *c, XMotionEvent *ev) { struct client *t; int x, y, pos; if (ISTILED(c)) { pos = layout_pos_index(c->mon->selws->layout, ev->x_root, ev->y_root); if (pos >= 0 && (t = find_nth_tiled_client(c->mon, pos))) monitor_swap(c->mon, c, t); } else if (ISMOVEABLE(c)) { x = ev->x_root + motion->attr.x - motion->start.x_root; y = ev->y_root + motion->attr.y - motion->start.y_root; client_move_resize(c, x, y, c->w, c->h, true, true); monitor_draw_bar(selmon); } }
void handler_configurerequest_resize(struct client *c, XConfigureRequestEvent *ev) { if (ev->value_mask & CWX) c->x = c->mon->mx + ev->x; if (ev->value_mask & CWY) c->y = c->mon->my + ev->y; if (ev->value_mask & CWWidth) c->w = ev->width; if (ev->value_mask & CWHeight) c->h = ev->height; if ((c->x + c->w) > c->mon->mx + c->mon->mw && c->floating) c->x = c->mon->mx + (c->mon->mw / 2 - WIDTH(c) / 2); if ((c->y + c->h) > c->mon->my + c->mon->mh && c->floating) c->y = c->mon->my + (c->mon->mh / 2 - HEIGHT(c) / 2); if (ISVISIBLE(c)) client_move_resize(c, c->x, c->y, c->w, c->h, false, false); }
static gboolean do_grow(ObActionsData *data, gint x, gint y, gint w, gint h) { gint realw, realh, lw, lh; realw = w; realh = h; client_try_configure(data->client, &x, &y, &realw, &realh, &lw, &lh, TRUE); /* if it's going to be resized smaller than it intended, don't move the window over */ if (x != data->client->area.x) x += w - realw; if (y != data->client->area.y) y += h - realh; if (x != data->client->area.x || y != data->client->area.y || realw != data->client->area.width || realh != data->client->area.height) { actions_client_move(data, TRUE); client_move_resize(data->client, x, y, realw, realh); actions_client_move(data, FALSE); return TRUE; } return FALSE; }