Skip to content

Commit 725582c

Browse files
authored
Merge pull request #1014 from cyphar/swaylock-fix-focus
sway: extensions: make locking give back focus
2 parents 36e48fc + 0925902 commit 725582c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

sway/extensions.c

+11-5
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,20 @@ void lock_surface_destructor(struct wl_resource *resource) {
6565
if (surface == resource) {
6666
list_del(desktop_shell.lock_surfaces, i);
6767
arrange_windows(&root_container, -1, -1);
68-
desktop_shell.is_locked = false;
6968
break;
7069
}
7170
}
71+
if (desktop_shell.lock_surfaces->length == 0) {
72+
sway_log(L_DEBUG, "Desktop shell unlocked");
73+
desktop_shell.is_locked = false;
74+
75+
// We need to now give focus back to the focus which we internally
76+
// track, since when we lock sway we don't actually change our internal
77+
// focus tracking.
78+
swayc_t *focus = get_focused_container(swayc_active_workspace());
79+
set_focused_container(focus);
80+
wlc_view_focus(focus->handle);
81+
}
7282
}
7383

7484
static void set_background(struct wl_client *client, struct wl_resource *resource,
@@ -157,10 +167,6 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou
157167
desktop_shell.is_locked = true;
158168
input_init();
159169
arrange_windows(workspace, -1, -1);
160-
swayc_t *focus_output = swayc_active_output();
161-
if (focus_output == output) {
162-
set_focused_container(view);
163-
}
164170
list_add(desktop_shell.lock_surfaces, surface);
165171
wl_resource_set_destructor(surface, lock_surface_destructor);
166172
} else {

0 commit comments

Comments
 (0)