Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use relative resizing #1051

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void cmd_node(char **args, int num, FILE *rsp)
if (sscanf(*args, "%i", &dx) == 1) {
num--, args++;
if (sscanf(*args, "%i", &dy) == 1) {
if (!resize_client(&trg, rh, dx, dy, true)) {
if (!resize_client(&trg, rh, dx, dy)) {
fail(rsp, "");
break;
}
Expand Down
6 changes: 1 addition & 5 deletions src/pointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,7 @@ void track_pointer(coordinates_t loc, pointer_action_t pac, xcb_point_t pos)
if (pac == ACTION_MOVE) {
move_client(&loc, dx, dy);
} else {
if (honor_size_hints) {
resize_client(&loc, rh, e->root_x, e->root_y, false);
} else {
resize_client(&loc, rh, dx, dy, true);
}
resize_client(&loc, rh, dx, dy);
}
last_motion_x = e->root_x;
last_motion_y = e->root_y;
Expand Down
32 changes: 5 additions & 27 deletions src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ bool move_client(coordinates_t *loc, int dx, int dy)
return true;
}

bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy, bool relative)
bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy)
{
node_t *n = loc->node;
if (n == NULL || n->client == NULL || n->client->state == STATE_FULLSCREEN) {
Expand All @@ -567,22 +567,14 @@ bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy, bool
}
if (vertical_fence != NULL) {
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 = vertical_fence->split_ratio + (double) dx / (double) vertical_fence->rectangle.width;
sr = MAX(0, sr);
sr = MIN(1, sr);
vertical_fence->split_ratio = sr;
}
if (horizontal_fence != NULL) {
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 = horizontal_fence->split_ratio + (double) dy / (double) horizontal_fence->rectangle.height;
sr = MAX(0, sr);
sr = MIN(1, sr);
horizontal_fence->split_ratio = sr;
Expand All @@ -591,22 +583,8 @@ bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy, bool
adjust_ratios(target_fence, target_fence->rectangle);
arrange(loc->monitor, loc->desktop);
} else {
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;
}
}
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));
width = MAX(1, w);
height = MAX(1, h);
apply_size_hints(n->client, &width, &height);
Expand Down
2 changes: 1 addition & 1 deletion src/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ uint32_t get_border_color(bool focused_node, bool focused_monitor);
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 relative);
bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy);
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);
Expand Down