mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 08:21:28 +00:00
wrap container in direction (if possible)
Introduces container wrapping - if there is no other viable move, the selection wraps on the first container where such action is possible.
This commit is contained in:
parent
fa119661e9
commit
7f558ce894
|
@ -1084,13 +1084,17 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
||||||
return container->fullscreen;
|
return container->fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swayc_t *wrap_candidate = NULL;
|
||||||
while (true) {
|
while (true) {
|
||||||
// Test if we can even make a difference here
|
// Test if we can even make a difference here
|
||||||
bool can_move = false;
|
bool can_move = false;
|
||||||
int diff = 0;
|
int diff = 0;
|
||||||
if (parent->type == C_ROOT) {
|
if (parent->type == C_ROOT) {
|
||||||
sway_log(L_DEBUG, "Moving between outputs");
|
|
||||||
swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true);
|
swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true);
|
||||||
|
if (!output || output == container) {
|
||||||
|
return wrap_candidate;
|
||||||
|
}
|
||||||
|
sway_log(L_DEBUG, "Moving between outputs");
|
||||||
return get_swayc_in_output_direction(output, dir);
|
return get_swayc_in_output_direction(output, dir);
|
||||||
} else {
|
} else {
|
||||||
if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
|
if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
|
||||||
|
@ -1108,8 +1112,18 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
||||||
|
|
||||||
if (can_move) {
|
if (can_move) {
|
||||||
int desired = index_child(container) + diff;
|
int desired = index_child(container) + diff;
|
||||||
if (container->is_floating || desired < 0 || desired >= parent->children->length) {
|
if (container->is_floating) {
|
||||||
can_move = false;
|
can_move = false;
|
||||||
|
} else if (desired < 0 || desired >= parent->children->length) {
|
||||||
|
can_move = false;
|
||||||
|
int len = parent->children->length;
|
||||||
|
if (!wrap_candidate && len > 1) {
|
||||||
|
if (desired < 0) {
|
||||||
|
wrap_candidate = parent->children->items[len-1];
|
||||||
|
} else {
|
||||||
|
wrap_candidate = parent->children->items[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return parent->children->items[desired];
|
return parent->children->items[desired];
|
||||||
}
|
}
|
||||||
|
@ -1118,8 +1132,8 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
||||||
container = parent;
|
container = parent;
|
||||||
parent = parent->parent;
|
parent = parent->parent;
|
||||||
if (!parent || container == limit) {
|
if (!parent || container == limit) {
|
||||||
// Nothing we can do
|
// wrapping is the last chance
|
||||||
return NULL;
|
return wrap_candidate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue