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.
This commit is contained in:
tokyo4j 2024-07-02 22:33:47 +09:00 committed by Hiroaki Yamamoto
parent 880522d142
commit 6bc93cf468
3 changed files with 17 additions and 1 deletions

View file

@ -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

View file

@ -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);

View file

@ -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;
}