From 90529532a7f7e10fa320d202b6692185ee3a08df Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sat, 9 Oct 2021 16:21:18 +0300 Subject: [PATCH 1/2] container: restore next to sibling after floating Follow-up to a558866f42de74f7dc0500c3fe29bb506cf03cf6 If seat_get_focus_inactive_tiling returns a non-view container, restore the floated container next to the previous sibling inside of the container instead of appending to the end. This matches i3 behavior. --- sway/tree/container.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index 6a01eab38..46ef4723c 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -861,7 +861,13 @@ void container_set_floating(struct sway_container *container, bool enable) { if (reference->view) { container_add_sibling(reference, container, 1); } else { - container_add_child(reference, container); + struct sway_container *sibling = + seat_get_focus_inactive_view(seat, &reference->node); + if (sibling) { + container_add_sibling(sibling, container, 1); + } else { + container_add_child(reference, container); + } } container->pending.width = reference->pending.width; container->pending.height = reference->pending.height; From 1cfd53e0478cd499c9bd68f3813b9163377947a7 Mon Sep 17 00:00:00 2001 From: siikamiika Date: Sun, 10 Oct 2021 23:01:07 +0300 Subject: [PATCH 2/2] container: remove unnecessary focus setting seat_get_focus_inactive_view will find the correct view anyway. --- sway/tree/container.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/sway/tree/container.c b/sway/tree/container.c index 46ef4723c..9ea7933f1 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c @@ -821,8 +821,6 @@ void container_set_floating(struct sway_container *container, bool enable) { struct sway_seat *seat = input_manager_current_seat(); struct sway_workspace *workspace = container->pending.workspace; - struct sway_container *focus = seat_get_focused_container(seat); - bool set_focus = focus == container; if (enable) { struct sway_container *old_parent = container->pending.parent; @@ -843,10 +841,6 @@ void container_set_floating(struct sway_container *container, bool enable) { container_floating_set_default_size(container); container_floating_resize_and_center(container); if (old_parent) { - if (set_focus) { - seat_set_raw_focus(seat, &old_parent->node); - seat_set_raw_focus(seat, &container->node); - } container_reap_empty(old_parent); } } else {