Fixes #752.
if (sscanf(*args, "%i", &dx) == 1) {
num--, args++;
if (sscanf(*args, "%i", &dy) == 1) {
- if (!resize_client(&trg, rh, dx, dy)) {
+ if (!resize_client(&trg, rh, dx, dy, true)) {
fail(rsp, "");
break;
}
if (pac == ACTION_MOVE) {
move_client(&loc, dx, dy);
} else {
- resize_client(&loc, rh, dx, dy);
+ resize_client(&loc, rh, e->root_x, e->root_y, false);
}
last_motion_x = e->root_x;
last_motion_y = e->root_y;
return true;
}
-bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy)
+bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy, bool relative)
{
node_t *n = loc->node;
if (n == NULL || n->client == NULL || n->client->state == STATE_FULLSCREEN) {
return false;
}
if (vertical_fence != NULL) {
- double sr = vertical_fence->split_ratio + (double) dx / vertical_fence->rectangle.width;
+ double sr = 0.0;
+ if (relative) {
+ sr = vertical_fence->split_ratio + (double) dx / (double) vertical_fence->rectangle.width;
+ } else {
+ sr = (double) (dx - vertical_fence->rectangle.x) / (double) vertical_fence->rectangle.width;
+ }
sr = MAX(0, sr);
sr = MIN(1, sr);
vertical_fence->split_ratio = sr;
}
if (horizontal_fence != NULL) {
- double sr = horizontal_fence->split_ratio + (double) dy / horizontal_fence->rectangle.height;
+ double sr = 0.0;
+ if (relative) {
+ sr = horizontal_fence->split_ratio + (double) dy / (double) horizontal_fence->rectangle.height;
+ } else {
+ sr = (double) (dy - horizontal_fence->rectangle.y) / (double) horizontal_fence->rectangle.height;
+ }
sr = MAX(0, sr);
sr = MIN(1, sr);
horizontal_fence->split_ratio = sr;
}
arrange(loc->monitor, loc->desktop);
} else {
- int w = width + dx * (rh & HANDLE_LEFT ? -1 : (rh & HANDLE_RIGHT ? 1 : 0));
- int h = height + dy * (rh & HANDLE_TOP ? -1 : (rh & HANDLE_BOTTOM ? 1 : 0));
+ int w = width, h = height;
+ if (relative) {
+ w += dx * (rh & HANDLE_LEFT ? -1 : (rh & HANDLE_RIGHT ? 1 : 0));
+ h += dy * (rh & HANDLE_TOP ? -1 : (rh & HANDLE_BOTTOM ? 1 : 0));
+ } else {
+ if (rh & HANDLE_LEFT) {
+ w = x + width - dx;
+ } else if (rh & HANDLE_RIGHT) {
+ w = dx - x;
+ }
+ if (rh & HANDLE_TOP) {
+ h = y + height - dy;
+ } else if (rh & HANDLE_BOTTOM) {
+ h = dy - y;
+ }
+ }
width = MAX(1, w);
height = MAX(1, h);
apply_size_hints(n->client, &width, &height);
void initialize_floating_rectangle(node_t *n);
xcb_rectangle_t get_window_rectangle(node_t *n);
bool move_client(coordinates_t *loc, int dx, int dy);
-bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy);
+bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy, bool relative);
void apply_size_hints(client_t *c, uint16_t *width, uint16_t *height);
void query_pointer(xcb_window_t *win, xcb_point_t *pt);
void update_motion_recorder(void);