diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-05-28 10:52:49 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-05-29 11:21:55 -0400 |
commit | a66fd74a547f1d6fa6b752314ddd674eb44b6da7 (patch) | |
tree | 23e3a81b60e420a9f93c582040c4711b2097e65e | |
parent | Merge pull request #2069 from RyanDwyer/ipc-workspace-representation (diff) | |
download | sway-a66fd74a547f1d6fa6b752314ddd674eb44b6da7.tar.gz sway-a66fd74a547f1d6fa6b752314ddd674eb44b6da7.tar.zst sway-a66fd74a547f1d6fa6b752314ddd674eb44b6da7.zip |
Fix breaking out of tabs/stacks
-rw-r--r-- | sway/tree/layout.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 1507eba9..96501cc3 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -309,6 +309,21 @@ static void workspace_rejigger(struct sway_container *ws, | |||
309 | arrange_workspace(ws); | 309 | arrange_workspace(ws); |
310 | } | 310 | } |
311 | 311 | ||
312 | static void move_out_of_tabs_stacks(struct sway_container *container, | ||
313 | struct sway_container *current, enum movement_direction move_dir, | ||
314 | int offs) { | ||
315 | wlr_log(L_DEBUG, "Moving out of tab/stack into a split"); | ||
316 | struct sway_container *old_parent = current->parent->parent; | ||
317 | struct sway_container *new_parent = container_split(current->parent, | ||
318 | move_dir == MOVE_LEFT || move_dir == MOVE_RIGHT ? L_HORIZ : L_VERT); | ||
319 | container_insert_child(new_parent, container, offs < 0 ? 0 : 1); | ||
320 | container_reap_empty_recursive(new_parent->parent); | ||
321 | container_flatten(new_parent->parent); | ||
322 | wl_signal_emit(¤t->events.reparent, old_parent); | ||
323 | container_create_notify(new_parent); | ||
324 | arrange_children_of(new_parent); | ||
325 | } | ||
326 | |||
312 | void container_move(struct sway_container *container, | 327 | void container_move(struct sway_container *container, |
313 | enum movement_direction move_dir, int move_amt) { | 328 | enum movement_direction move_dir, int move_amt) { |
314 | if (!sway_assert( | 329 | if (!sway_assert( |
@@ -390,6 +405,10 @@ void container_move(struct sway_container *container, | |||
390 | arrange_workspace(current); | 405 | arrange_workspace(current); |
391 | } | 406 | } |
392 | return; | 407 | return; |
408 | } else if (current->layout == L_TABBED | ||
409 | || current->layout == L_STACKED) { | ||
410 | wlr_log(L_DEBUG, "Rejiggering out of tabs/stacks"); | ||
411 | workspace_rejigger(current, container, move_dir); | ||
393 | } else { | 412 | } else { |
394 | wlr_log(L_DEBUG, "Selecting output"); | 413 | wlr_log(L_DEBUG, "Selecting output"); |
395 | current = current->parent; | 414 | current = current->parent; |
@@ -401,8 +420,15 @@ void container_move(struct sway_container *container, | |||
401 | if ((index == parent->children->length - 1 && offs > 0) | 420 | if ((index == parent->children->length - 1 && offs > 0) |
402 | || (index == 0 && offs < 0)) { | 421 | || (index == 0 && offs < 0)) { |
403 | if (current->parent == container->parent) { | 422 | if (current->parent == container->parent) { |
404 | wlr_log(L_DEBUG, "Hit limit, selecting parent"); | 423 | if (parent->layout == L_TABBED |
405 | current = current->parent; | 424 | || parent->layout == L_STACKED) { |
425 | move_out_of_tabs_stacks(container, current, | ||
426 | move_dir, offs); | ||
427 | return; | ||
428 | } else { | ||
429 | wlr_log(L_DEBUG, "Hit limit, selecting parent"); | ||
430 | current = current->parent; | ||
431 | } | ||
406 | } else { | 432 | } else { |
407 | wlr_log(L_DEBUG, "Hit limit, " | 433 | wlr_log(L_DEBUG, "Hit limit, " |
408 | "promoting descendant to sibling"); | 434 | "promoting descendant to sibling"); |
@@ -419,6 +445,10 @@ void container_move(struct sway_container *container, | |||
419 | sibling = parent->children->items[index + offs]; | 445 | sibling = parent->children->items[index + offs]; |
420 | wlr_log(L_DEBUG, "Selecting sibling id:%zd", sibling->id); | 446 | wlr_log(L_DEBUG, "Selecting sibling id:%zd", sibling->id); |
421 | } | 447 | } |
448 | } else if (parent->layout == L_TABBED | ||
449 | || parent->layout == L_STACKED) { | ||
450 | move_out_of_tabs_stacks(container, current, move_dir, offs); | ||
451 | return; | ||
422 | } else { | 452 | } else { |
423 | wlr_log(L_DEBUG, "Moving up to find a parallel container"); | 453 | wlr_log(L_DEBUG, "Moving up to find a parallel container"); |
424 | current = current->parent; | 454 | current = current->parent; |