1
1
mirror of https://github.com/swaywm/sway synced 2024-11-18 23:14:03 +01:00

Fixed resizing

This commit is contained in:
Luminarys 2015-08-21 19:36:57 -05:00
parent 2a799a731f
commit 63a3236064
2 changed files with 34 additions and 5 deletions

@ -448,6 +448,8 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
return false;
}
char *end;
int min_sane_w = 100;
int min_sane_h = 60;
int amount = (int)strtol(argv[2], &end, 10);
if (errno == ERANGE || amount == 0) {
errno = 0;
@ -496,6 +498,7 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
sway_log(L_DEBUG, "Found the proper parent: %p. It has %d l conts, and %d r conts", parent->parent, lnumber, rnumber);
//TODO: Ensure rounding is done in such a way that there are NO pixel leaks
for (i = 0; i < parent->parent->children->length; i++) {
bool valid = true;
sibling = parent->parent->children->items[i];
if (sibling->x != focused->x) {
if (sibling->x < parent->x) {

@ -422,9 +422,25 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
bool valid = true;
double dx = mouse_origin.x - prev_pos.x;
double dy = mouse_origin.y - prev_pos.y;
if (view != pointer_state.tiling.init_view) {
changed_tiling = true;
valid = false;
if (view->type != C_WORKSPACE) {
if (view->x < pointer_state.tiling.init_view->x) {
pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20;
pointer_state.lock.temp_left = true;
} else if (view->x > pointer_state.tiling.init_view->x) {
pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20;
pointer_state.lock.temp_right = true;
}
if (view->y < pointer_state.tiling.init_view->y) {
pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
pointer_state.lock.temp_up = true;
} else if (view->y > pointer_state.tiling.init_view->y) {
pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
pointer_state.lock.temp_down = true;
}
}
}
if ((dx < 0 || mouse_origin.x < pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_left) {
@ -432,6 +448,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
valid = false;
} else if (dx > 0 && pointer_state.lock.temp_left) {
pointer_state.lock.temp_left = false;
pointer_state.tiling.lock_pos.x = 0;
}
if ((dx > 0 || mouse_origin.x > pointer_state.tiling.lock_pos.x) && pointer_state.lock.temp_right) {
@ -439,6 +456,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
valid = false;
} else if (dx < 0 && pointer_state.lock.temp_right) {
pointer_state.lock.temp_right = false;
pointer_state.tiling.lock_pos.x = 0;
}
if ((dy < 0 || mouse_origin.y < pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_up) {
@ -446,6 +464,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
valid = false;
} else if (dy > 0 && pointer_state.lock.temp_up) {
pointer_state.lock.temp_up = false;
pointer_state.tiling.lock_pos.y = 0;
}
if ((dy > 0 || mouse_origin.y > pointer_state.tiling.lock_pos.y) && pointer_state.lock.temp_down) {
@ -453,6 +472,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
valid = false;
} else if (dy < 0 && pointer_state.lock.temp_down) {
pointer_state.lock.temp_down = false;
pointer_state.tiling.lock_pos.y = 0;
}
if (!view->is_floating && valid) {
@ -477,10 +497,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP);
changed_tiling = true;
} else {
pointer_state.tiling.lock_pos.y = mouse_origin.y;
if (parent->height < min_sane_h) {
//pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
pointer_state.lock.temp_up = true;
} else if (sibling->height < min_sane_h) {
pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
pointer_state.lock.temp_down = true;
}
}
@ -502,10 +524,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM);
changed_tiling = true;
} else {
pointer_state.tiling.lock_pos.y = mouse_origin.y;
if (parent->height < min_sane_h) {
//pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + pointer_state.tiling.init_view->height - 20;
pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
pointer_state.lock.temp_down = true;
} else if (sibling->height < min_sane_h) {
pointer_state.tiling.lock_pos.y = pointer_state.tiling.init_view->y + 20;
pointer_state.lock.temp_up = true;
}
}
@ -531,11 +555,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT);
changed_tiling = true;
} else {
pointer_state.tiling.lock_pos.x = mouse_origin.x;
if (parent->width < min_sane_w) {
pointer_state.lock.temp_left = true;
pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20;
} else if (sibling->width < min_sane_w) {
pointer_state.lock.temp_right = true;
pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + pointer_state.tiling.init_view->width - 20;
}
}
}
@ -556,11 +581,12 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT);
changed_tiling = true;
} else {
pointer_state.tiling.lock_pos.x = mouse_origin.x;
if (parent->width < min_sane_w) {
pointer_state.lock.temp_right = true;
pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20;
} else if (sibling->width < min_sane_w) {
pointer_state.lock.temp_left = true;
pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20;
}
}
}