diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2021-10-10 17:27:43 +0300 |
---|---|---|
committer | Ronan Pigott <rpigott@berkeley.edu> | 2021-10-21 13:16:36 -0700 |
commit | 21d2fdf74c93a4d1df5dd2dc0d6bf24c611dd752 (patch) | |
tree | c4da2870530786e99635b8fbc354b073097ab470 | |
parent | commands/focus: focus view inside container (diff) | |
download | sway-21d2fdf74c93a4d1df5dd2dc0d6bf24c611dd752.tar.gz sway-21d2fdf74c93a4d1df5dd2dc0d6bf24c611dd752.tar.zst sway-21d2fdf74c93a4d1df5dd2dc0d6bf24c611dd752.zip |
view: add new container as a sibling of tiled view
If the focused container is floating by itself, create a new container
in tiling mode as a sibling of the inactive focused container instead of
creating it as a sibling of everything that is in tiling mode in that
workspace. This is the i3 behavior.
-rw-r--r-- | sway/tree/view.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index b2f70d70..bd53a5c8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -729,10 +729,29 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
729 | } | 729 | } |
730 | 730 | ||
731 | struct sway_seat *seat = input_manager_current_seat(); | 731 | struct sway_seat *seat = input_manager_current_seat(); |
732 | struct sway_node *node = ws ? seat_get_focus_inactive(seat, &ws->node) | 732 | struct sway_node *node = |
733 | : seat_get_focus_inactive(seat, &root->node); | 733 | seat_get_focus_inactive(seat, ws ? &ws->node : &root->node); |
734 | struct sway_container *target_sibling = node->type == N_CONTAINER ? | 734 | struct sway_container *target_sibling = NULL; |
735 | node->sway_container : NULL; | 735 | if (node && node->type == N_CONTAINER) { |
736 | if (container_is_floating(node->sway_container)) { | ||
737 | // If we're about to launch the view into the floating container, then | ||
738 | // launch it as a tiled view instead. | ||
739 | if (ws) { | ||
740 | target_sibling = seat_get_focus_inactive_tiling(seat, ws); | ||
741 | if (target_sibling) { | ||
742 | struct sway_container *con = | ||
743 | seat_get_focus_inactive_view(seat, &target_sibling->node); | ||
744 | if (con) { | ||
745 | target_sibling = con; | ||
746 | } | ||
747 | } | ||
748 | } else { | ||
749 | ws = seat_get_last_known_workspace(seat); | ||
750 | } | ||
751 | } else { | ||
752 | target_sibling = node->sway_container; | ||
753 | } | ||
754 | } | ||
736 | 755 | ||
737 | view->foreign_toplevel = | 756 | view->foreign_toplevel = |
738 | wlr_foreign_toplevel_handle_v1_create(server.foreign_toplevel_manager); | 757 | wlr_foreign_toplevel_handle_v1_create(server.foreign_toplevel_manager); |
@@ -749,13 +768,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
749 | wl_signal_add(&view->foreign_toplevel->events.destroy, | 768 | wl_signal_add(&view->foreign_toplevel->events.destroy, |
750 | &view->foreign_destroy); | 769 | &view->foreign_destroy); |
751 | 770 | ||
752 | // If we're about to launch the view into the floating container, then | ||
753 | // launch it as a tiled view in the root of the workspace instead. | ||
754 | if (target_sibling && container_is_floating(target_sibling)) { | ||
755 | target_sibling = NULL; | ||
756 | ws = seat_get_last_known_workspace(seat); | ||
757 | } | ||
758 | |||
759 | struct sway_container *container = view->container; | 771 | struct sway_container *container = view->container; |
760 | if (target_sibling) { | 772 | if (target_sibling) { |
761 | container_add_sibling(target_sibling, container, 1); | 773 | container_add_sibling(target_sibling, container, 1); |