Skip to content

Commit f21090f

Browse files
anpandeyrpigott
authored andcommitted
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.
1 parent 90c2d63 commit f21090f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sway/tree/root.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ void root_scratchpad_show(struct sway_container *con) {
145145
// Show the container
146146
if (old_ws) {
147147
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);
149152
} else {
150153
// Act on the ancestor of scratchpad hidden split containers
151154
while (con->pending.parent) {
@@ -163,6 +166,9 @@ void root_scratchpad_show(struct sway_container *con) {
163166

164167
arrange_workspace(new_ws);
165168
seat_set_focus(seat, seat_get_focus_inactive(seat, &con->node));
169+
if (old_ws) {
170+
workspace_consider_destroy(old_ws);
171+
}
166172
}
167173

168174
static void disable_fullscreen(struct sway_container *con, void *data) {

0 commit comments

Comments
 (0)