diff options
author | Ankit Pandey <anpandey@protonmail.com> | 2023-03-18 04:58:53 -0700 |
---|---|---|
committer | Ronan Pigott <ronan@rjp.ie> | 2023-03-24 13:20:13 -0700 |
commit | f21090f97870af2592f801fef316984200aa6678 (patch) | |
tree | 9ff6ee98770b399c440df01fb69b7569d377771d | |
parent | root: Try to preserve relative positions of floating containers (diff) | |
download | sway-f21090f97870af2592f801fef316984200aa6678.tar.gz sway-f21090f97870af2592f801fef316984200aa6678.tar.zst sway-f21090f97870af2592f801fef316984200aa6678.zip |
root: Set inactive focus when scratchpad is moved to new workspace
Fixes an issue where an already visible scratchpad window being moved due to
'scratchpad show' leaves the entire workspace at the top of the focus stack in
the old workspace. Moving by 'focus output' back to the old workspace would
focus the entire workspace instead of just the last active container.
-rw-r--r-- | sway/tree/root.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sway/tree/root.c b/sway/tree/root.c index 233358d2..831c75a5 100644 --- a/sway/tree/root.c +++ b/sway/tree/root.c | |||
@@ -145,7 +145,10 @@ void root_scratchpad_show(struct sway_container *con) { | |||
145 | // Show the container | 145 | // Show the container |
146 | if (old_ws) { | 146 | if (old_ws) { |
147 | container_detach(con); | 147 | container_detach(con); |
148 | workspace_consider_destroy(old_ws); | 148 | // Make sure the last inactive container on the old workspace is above |
149 | // the workspace itself in the focus stack. | ||
150 | struct sway_node *node = seat_get_focus_inactive(seat, &old_ws->node); | ||
151 | seat_set_raw_focus(seat, node); | ||
149 | } else { | 152 | } else { |
150 | // Act on the ancestor of scratchpad hidden split containers | 153 | // Act on the ancestor of scratchpad hidden split containers |
151 | while (con->pending.parent) { | 154 | while (con->pending.parent) { |
@@ -163,6 +166,9 @@ void root_scratchpad_show(struct sway_container *con) { | |||
163 | 166 | ||
164 | arrange_workspace(new_ws); | 167 | arrange_workspace(new_ws); |
165 | seat_set_focus(seat, seat_get_focus_inactive(seat, &con->node)); | 168 | seat_set_focus(seat, seat_get_focus_inactive(seat, &con->node)); |
169 | if (old_ws) { | ||
170 | workspace_consider_destroy(old_ws); | ||
171 | } | ||
166 | } | 172 | } |
167 | 173 | ||
168 | static void disable_fullscreen(struct sway_container *con, void *data) { | 174 | static void disable_fullscreen(struct sway_container *con, void *data) { |