From: tokyo4j Date: Tue, 2 Jul 2024 13:33:47 +0000 (+0900) Subject: session-lock: restore focused view on unlock X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=6bc93cf4687aa764d795bbe2b4220fe3cbadb0b6;p=proto%2Flabwc.git session-lock: restore focused view on unlock Before this commit, the topmost view is focused on unlock. This commit changes it to remember the focused view on lock then restore it on unlock. --- diff --git a/include/session-lock.h b/include/session-lock.h index c8961731..715c859f 100644 --- a/include/session-lock.h +++ b/include/session-lock.h @@ -10,6 +10,8 @@ struct server; struct session_lock_manager { struct server *server; struct wlr_session_lock_manager_v1 *wlr_manager; + /* View re-focused on unlock */ + struct view *last_active_view; struct wlr_surface *focused; /* * When not locked: lock=NULL, locked=false diff --git a/src/session-lock.c b/src/session-lock.c index 09b62784..9bb54d1a 100644 --- a/src/session-lock.c +++ b/src/session-lock.c @@ -269,7 +269,14 @@ handle_lock_unlock(struct wl_listener *listener, void *data) wl_container_of(listener, manager, lock_unlock); session_lock_destroy(manager); manager->locked = false; - desktop_focus_topmost_view(manager->server); + + if (manager->last_active_view) { + desktop_focus_view(manager->last_active_view, /* raise */ false); + } else { + desktop_focus_topmost_view(manager->server); + } + manager->last_active_view = NULL; + cursor_update_focus(manager->server); } @@ -309,6 +316,9 @@ handle_new_session_lock(struct wl_listener *listener, void *data) } assert(wl_list_empty(&manager->lock_outputs)); + /* Remember the focused view to restore it on unlock */ + manager->last_active_view = manager->server->active_view; + struct output *output; wl_list_for_each(output, &manager->server->outputs, link) { session_lock_output_create(manager, output); diff --git a/src/view.c b/src/view.c index 1646decd..481ec195 100644 --- a/src/view.c +++ b/src/view.c @@ -2396,6 +2396,10 @@ view_destroy(struct view *view) server->active_view = NULL; } + if (server->session_lock_manager->last_active_view == view) { + server->session_lock_manager->last_active_view = NULL; + } + if (server->last_raised_view == view) { server->last_raised_view = NULL; }