mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 18:01:29 +00:00
Added mouse resize for auto layouts
This commit is contained in:
parent
1f47c58d63
commit
f24ebd75fa
|
@ -1372,7 +1372,8 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
||||||
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 desired;
|
||||||
|
int idx = index_child(container);
|
||||||
if (parent->type == C_ROOT) {
|
if (parent->type == C_ROOT) {
|
||||||
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) {
|
if (!output || output == container) {
|
||||||
|
@ -1381,21 +1382,36 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
||||||
sway_log(L_DEBUG, "Moving between outputs");
|
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 (is_auto_layout(parent->layout)) {
|
||||||
if (parent->layout == L_HORIZ || parent->layout == L_TABBED) {
|
bool is_major = parent->layout == L_AUTO_LEFT || parent->layout == L_AUTO_RIGHT
|
||||||
can_move = true;
|
? dir == MOVE_LEFT || dir == MOVE_RIGHT
|
||||||
diff = dir == MOVE_LEFT ? -1 : 1;
|
: dir == MOVE_DOWN || dir == MOVE_UP;
|
||||||
|
size_t gidx = auto_group_index(parent, idx);
|
||||||
|
if (is_major) {
|
||||||
|
size_t desired_grp = gidx + (dir == MOVE_RIGHT || dir == MOVE_DOWN ? 1 : -1);
|
||||||
|
can_move = auto_group_bounds(parent, desired_grp, &desired, NULL);
|
||||||
|
} else {
|
||||||
|
desired = idx + (dir == MOVE_RIGHT || dir == MOVE_DOWN ? 1 : -1);
|
||||||
|
int start, end;
|
||||||
|
can_move = auto_group_bounds(parent, gidx, &start, &end)
|
||||||
|
&& desired >= start && desired < end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (parent->layout == L_VERT || parent->layout == L_STACKED) {
|
if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
|
||||||
can_move = true;
|
if (parent->layout == L_HORIZ || parent->layout == L_TABBED) {
|
||||||
diff = dir == MOVE_UP ? -1 : 1;
|
can_move = true;
|
||||||
|
desired = idx + (dir == MOVE_LEFT ? -1 : 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (parent->layout == L_VERT || parent->layout == L_STACKED) {
|
||||||
|
can_move = true;
|
||||||
|
desired = idx + (dir == MOVE_UP ? -1 : 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (can_move) {
|
if (can_move) {
|
||||||
int desired = index_child(container) + diff;
|
|
||||||
if (container->is_floating) {
|
if (container->is_floating) {
|
||||||
if (desired < 0) {
|
if (desired < 0) {
|
||||||
wrap_candidate = parent->floating->items[parent->floating->length-1];
|
wrap_candidate = parent->floating->items[parent->floating->length-1];
|
||||||
|
@ -1422,6 +1438,8 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
sway_log(L_DEBUG, "%s cont %d-%p dir %i sibling %d: %p", __func__,
|
||||||
|
idx, container, dir, desired, parent->children->items[desired]);
|
||||||
return parent->children->items[desired];
|
return parent->children->items[desired];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1590,7 +1608,7 @@ size_t auto_group_index(const swayc_t *container, int index) {
|
||||||
} else {
|
} else {
|
||||||
grp_idx = (nb_slave_grp - remainder) + (index - idx2) / (grp_sz + 1) ;
|
grp_idx = (nb_slave_grp - remainder) + (index - idx2) / (grp_sz + 1) ;
|
||||||
}
|
}
|
||||||
return grp_idx + (master_first ? 1 : 0);
|
return grp_idx + (master_first && container-> nb_master ? 1 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue