diff options
author | Ronan Pigott <rpigott@berkeley.edu> | 2021-04-11 17:02:55 -0700 |
---|---|---|
committer | Tudor Brindus <me@tbrindus.ca> | 2021-04-11 21:01:33 -0400 |
commit | a558866f42de74f7dc0500c3fe29bb506cf03cf6 (patch) | |
tree | 6b6312ed03555eb9d2d875f09bc747a109737b86 | |
parent | 1a72049c04b8c6e1a30f80b3887fc7808a717935 (diff) |
container: retain focus position on floating enable
When a tiling container is floated, the focus stack needs to be
appropraitely modified to return the container to its original
position in the tree upon floating disable, like i3.
-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) { 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; @@ -835,6 +837,10 @@ 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 { @@ -846,7 +852,11 @@ void container_set_floating(struct sway_container *container, bool enable) { struct sway_container *reference = seat_get_focus_inactive_tiling(seat, workspace); if (reference) { - container_add_sibling(reference, container, 1); + if (reference->view) { + container_add_sibling(reference, container, 1); + } else { + container_add_child(reference, container); + } container->pending.width = reference->pending.width; container->pending.height = reference->pending.height; } else { |