diff options
-rw-r--r-- | sway/tree/container.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 68fbec2f..67e69d9d 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -821,6 +821,8 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
821 | 821 | ||
822 | struct sway_seat *seat = input_manager_current_seat(); | 822 | struct sway_seat *seat = input_manager_current_seat(); |
823 | struct sway_workspace *workspace = container->pending.workspace; | 823 | struct sway_workspace *workspace = container->pending.workspace; |
824 | struct sway_container *focus = seat_get_focused_container(seat); | ||
825 | bool set_focus = focus == container; | ||
824 | 826 | ||
825 | if (enable) { | 827 | if (enable) { |
826 | struct sway_container *old_parent = container->pending.parent; | 828 | struct sway_container *old_parent = container->pending.parent; |
@@ -835,6 +837,10 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
835 | container_floating_set_default_size(container); | 837 | container_floating_set_default_size(container); |
836 | container_floating_resize_and_center(container); | 838 | container_floating_resize_and_center(container); |
837 | if (old_parent) { | 839 | if (old_parent) { |
840 | if (set_focus) { | ||
841 | seat_set_raw_focus(seat, &old_parent->node); | ||
842 | seat_set_raw_focus(seat, &container->node); | ||
843 | } | ||
838 | container_reap_empty(old_parent); | 844 | container_reap_empty(old_parent); |
839 | } | 845 | } |
840 | } else { | 846 | } else { |
@@ -846,7 +852,11 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
846 | struct sway_container *reference = | 852 | struct sway_container *reference = |
847 | seat_get_focus_inactive_tiling(seat, workspace); | 853 | seat_get_focus_inactive_tiling(seat, workspace); |
848 | if (reference) { | 854 | if (reference) { |
849 | container_add_sibling(reference, container, 1); | 855 | if (reference->view) { |
856 | container_add_sibling(reference, container, 1); | ||
857 | } else { | ||
858 | container_add_child(reference, container); | ||
859 | } | ||
850 | container->pending.width = reference->pending.width; | 860 | container->pending.width = reference->pending.width; |
851 | container->pending.height = reference->pending.height; | 861 | container->pending.height = reference->pending.height; |
852 | } else { | 862 | } else { |