From 29a535aae4ff631aced5753b45ef32a5f1b342dc Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Mon, 26 Dec 2016 19:23:07 +1100 Subject: sway: extensions: only unlock if lock_surfaces.length == 0 When destroying lock surfaces, we really should only unlock a desktop_shell if the set of lock surfaces has dropped to zero (since callers need to do a set_lock_surface for every output). Signed-off-by: Aleksa Sarai --- sway/extensions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sway/extensions.c b/sway/extensions.c index 40702e28..547aa931 100644 --- a/sway/extensions.c +++ b/sway/extensions.c @@ -65,10 +65,12 @@ void lock_surface_destructor(struct wl_resource *resource) { if (surface == resource) { list_del(desktop_shell.lock_surfaces, i); arrange_windows(&root_container, -1, -1); - desktop_shell.is_locked = false; break; } } + if (desktop_shell.lock_surfaces->length == 0) { + desktop_shell.is_locked = false; + } } static void set_background(struct wl_client *client, struct wl_resource *resource, -- cgit v1.2.3-54-g00ecf From 09259021abed0ebc75e214ebf947ceef6d458aa7 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Mon, 26 Dec 2016 19:35:12 +1100 Subject: sway: extensions: make locking give back focus Don't switch the internal tracking of focus to the swaylock surface, to allow for switching back to the previously active window (or the currently active window, if some new process changed). Signed-off-by: Aleksa Sarai --- sway/extensions.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sway/extensions.c b/sway/extensions.c index 547aa931..5fee7d38 100644 --- a/sway/extensions.c +++ b/sway/extensions.c @@ -69,7 +69,15 @@ void lock_surface_destructor(struct wl_resource *resource) { } } if (desktop_shell.lock_surfaces->length == 0) { + sway_log(L_DEBUG, "Desktop shell unlocked"); desktop_shell.is_locked = false; + + // We need to now give focus back to the focus which we internally + // track, since when we lock sway we don't actually change our internal + // focus tracking. + swayc_t *focus = get_focused_container(swayc_active_workspace()); + set_focused_container(focus); + wlc_view_focus(focus->handle); } } @@ -159,10 +167,6 @@ static void set_lock_surface(struct wl_client *client, struct wl_resource *resou desktop_shell.is_locked = true; input_init(); arrange_windows(workspace, -1, -1); - swayc_t *focus_output = swayc_active_output(); - if (focus_output == output) { - set_focused_container(view); - } list_add(desktop_shell.lock_surfaces, surface); wl_resource_set_destructor(surface, lock_surface_destructor); } else { -- cgit v1.2.3-54-g00ecf