summaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar wil <william.barsse@gmail.com>2017-01-07 21:24:43 +0100
committerLibravatar wil <william.barsse@gmail.com>2017-01-07 21:24:43 +0100
commitf24ebd75fa3ce35e844d5f6e71f3052025aa7995 (patch)
tree92cf7e7d66cff02bd57d3162ee4799adee2c457d /sway
parentsimplification of apply_auto_layout (diff)
downloadsway-f24ebd75fa3ce35e844d5f6e71f3052025aa7995.tar.gz
sway-f24ebd75fa3ce35e844d5f6e71f3052025aa7995.tar.zst
sway-f24ebd75fa3ce35e844d5f6e71f3052025aa7995.zip
Added mouse resize for auto layouts
Diffstat (limited to 'sway')
-rw-r--r--sway/layout.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/sway/layout.c b/sway/layout.c
index 6a2af2a6..e2f31848 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -1372,7 +1372,8 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
1372 while (true) { 1372 while (true) {
1373 // Test if we can even make a difference here 1373 // Test if we can even make a difference here
1374 bool can_move = false; 1374 bool can_move = false;
1375 int diff = 0; 1375 int desired;
1376 int idx = index_child(container);
1376 if (parent->type == C_ROOT) { 1377 if (parent->type == C_ROOT) {
1377 swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true); 1378 swayc_t *output = swayc_adjacent_output(container, dir, &abs_pos, true);
1378 if (!output || output == container) { 1379 if (!output || output == container) {
@@ -1381,21 +1382,36 @@ swayc_t *get_swayc_in_direction_under(swayc_t *container, enum movement_directio
1381 sway_log(L_DEBUG, "Moving between outputs"); 1382 sway_log(L_DEBUG, "Moving between outputs");
1382 return get_swayc_in_output_direction(output, dir); 1383 return get_swayc_in_output_direction(output, dir);
1383 } else { 1384 } else {
1384 if (dir == MOVE_LEFT || dir == MOVE_RIGHT) { 1385 if (is_auto_layout(parent->layout)) {
1385 if (parent->layout == L_HORIZ || parent->layout == L_TABBED) { 1386 bool is_major = parent->layout == L_AUTO_LEFT || parent->layout == L_AUTO_RIGHT
1386 can_move = true; 1387 ? dir == MOVE_LEFT || dir == MOVE_RIGHT
1387 diff = dir == MOVE_LEFT ? -1 : 1; 1388 : dir == MOVE_DOWN || dir == MOVE_UP;
1389 size_t gidx = auto_group_index(parent, idx);
1390 if (is_major) {
1391 size_t desired_grp = gidx + (dir == MOVE_RIGHT || dir == MOVE_DOWN ? 1 : -1);
1392 can_move = auto_group_bounds(parent, desired_grp, &desired, NULL);
1393 } else {
1394 desired = idx + (dir == MOVE_RIGHT || dir == MOVE_DOWN ? 1 : -1);
1395 int start, end;
1396 can_move = auto_group_bounds(parent, gidx, &start, &end)
1397 && desired >= start && desired < end;
1388 } 1398 }
1389 } else { 1399 } else {
1390 if (parent->layout == L_VERT || parent->layout == L_STACKED) { 1400 if (dir == MOVE_LEFT || dir == MOVE_RIGHT) {
1391 can_move = true; 1401 if (parent->layout == L_HORIZ || parent->layout == L_TABBED) {
1392 diff = dir == MOVE_UP ? -1 : 1; 1402 can_move = true;
1403 desired = idx + (dir == MOVE_LEFT ? -1 : 1);
1404 }
1405 } else {
1406 if (parent->layout == L_VERT || parent->layout == L_STACKED) {
1407 can_move = true;
1408 desired = idx + (dir == MOVE_UP ? -1 : 1);
1409 }
1393 } 1410 }
1394 } 1411 }
1395 } 1412 }
1396 1413
1397 if (can_move) { 1414 if (can_move) {
1398 int desired = index_child(container) + diff;
1399 if (container->is_floating) { 1415 if (container->is_floating) {
1400 if (desired < 0) { 1416 if (desired < 0) {
1401 wrap_candidate = parent->floating->items[parent->floating->length-1]; 1417 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
1422 } 1438 }
1423 } 1439 }
1424 } else { 1440 } else {
1441 sway_log(L_DEBUG, "%s cont %d-%p dir %i sibling %d: %p", __func__,
1442 idx, container, dir, desired, parent->children->items[desired]);
1425 return parent->children->items[desired]; 1443 return parent->children->items[desired];
1426 } 1444 }
1427 } 1445 }
@@ -1590,7 +1608,7 @@ size_t auto_group_index(const swayc_t *container, int index) {
1590 } else { 1608 } else {
1591 grp_idx = (nb_slave_grp - remainder) + (index - idx2) / (grp_sz + 1) ; 1609 grp_idx = (nb_slave_grp - remainder) + (index - idx2) / (grp_sz + 1) ;
1592 } 1610 }
1593 return grp_idx + (master_first ? 1 : 0); 1611 return grp_idx + (master_first && container-> nb_master ? 1 : 0);
1594 } 1612 }
1595} 1613}
1596 1614