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

View file

@ -448,6 +448,8 @@ static bool cmd_resize(struct sway_config *config, int argc, char **argv) {
return false; return false;
} }
char *end; char *end;
int min_sane_w = 100;
int min_sane_h = 60;
int amount = (int)strtol(argv[2], &end, 10); int amount = (int)strtol(argv[2], &end, 10);
if (errno == ERANGE || amount == 0) { if (errno == ERANGE || amount == 0) {
errno = 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); 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 //TODO: Ensure rounding is done in such a way that there are NO pixel leaks
for (i = 0; i < parent->parent->children->length; i++) { for (i = 0; i < parent->parent->children->length; i++) {
bool valid = true;
sibling = parent->parent->children->items[i]; sibling = parent->parent->children->items[i];
if (sibling->x != focused->x) { if (sibling->x != focused->x) {
if (sibling->x < parent->x) { if (sibling->x < parent->x) {

View file

@ -422,9 +422,25 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
bool valid = true; bool valid = true;
double dx = mouse_origin.x - prev_pos.x; double dx = mouse_origin.x - prev_pos.x;
double dy = mouse_origin.y - prev_pos.y; double dy = mouse_origin.y - prev_pos.y;
if (view != pointer_state.tiling.init_view) { if (view != pointer_state.tiling.init_view) {
changed_tiling = true;
valid = false; 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) { 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; valid = false;
} else if (dx > 0 && pointer_state.lock.temp_left) { } else if (dx > 0 && pointer_state.lock.temp_left) {
pointer_state.lock.temp_left = false; 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) { 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; valid = false;
} else if (dx < 0 && pointer_state.lock.temp_right) { } else if (dx < 0 && pointer_state.lock.temp_right) {
pointer_state.lock.temp_right = false; 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) { 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; valid = false;
} else if (dy > 0 && pointer_state.lock.temp_up) { } else if (dy > 0 && pointer_state.lock.temp_up) {
pointer_state.lock.temp_up = false; 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) { 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; valid = false;
} else if (dy < 0 && pointer_state.lock.temp_down) { } else if (dy < 0 && pointer_state.lock.temp_down) {
pointer_state.lock.temp_down = false; pointer_state.lock.temp_down = false;
pointer_state.tiling.lock_pos.y = 0;
} }
if (!view->is_floating && valid) { 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); recursive_resize(sibling, -1 * dy, WLC_RESIZE_EDGE_TOP);
changed_tiling = true; changed_tiling = true;
} else { } else {
pointer_state.tiling.lock_pos.y = mouse_origin.y;
if (parent->height < min_sane_h) { 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; pointer_state.lock.temp_up = true;
} else if (sibling->height < min_sane_h) { } 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; 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); recursive_resize(sibling, dy, WLC_RESIZE_EDGE_BOTTOM);
changed_tiling = true; changed_tiling = true;
} else { } else {
pointer_state.tiling.lock_pos.y = mouse_origin.y;
if (parent->height < min_sane_h) { 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; pointer_state.lock.temp_down = true;
} else if (sibling->height < min_sane_h) { } 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; 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); recursive_resize(sibling, -1 * dx, WLC_RESIZE_EDGE_LEFT);
changed_tiling = true; changed_tiling = true;
} else { } else {
pointer_state.tiling.lock_pos.x = mouse_origin.x;
if (parent->width < min_sane_w) { if (parent->width < min_sane_w) {
pointer_state.lock.temp_left = true; 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) { } else if (sibling->width < min_sane_w) {
pointer_state.lock.temp_right = true; 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); recursive_resize(sibling, dx, WLC_RESIZE_EDGE_RIGHT);
changed_tiling = true; changed_tiling = true;
} else { } else {
pointer_state.tiling.lock_pos.x = mouse_origin.x;
if (parent->width < min_sane_w) { if (parent->width < min_sane_w) {
pointer_state.lock.temp_right = true; 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) { } else if (sibling->width < min_sane_w) {
pointer_state.lock.temp_left = true; pointer_state.lock.temp_left = true;
pointer_state.tiling.lock_pos.x = pointer_state.tiling.init_view->x + 20;
} }
} }
} }