]> git.mdlowis.com Git - proto/labwc.git/commitdiff
session-lock: restore focused view on unlock
authortokyo4j <hrak1529@gmail.com>
Tue, 2 Jul 2024 13:33:47 +0000 (22:33 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Sun, 7 Jul 2024 06:48:32 +0000 (15:48 +0900)
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.

include/session-lock.h
src/session-lock.c
src/view.c

index c8961731dd3332ebfc962d6a56705e7ed0b1841c..715c859f89a9071a5c998d1827ce362792d12f3e 100644 (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
index 09b62784b923db92134d152f07e8e64cbf2edf71..9bb54d1a148a98849eda27ecdf7fba017111cdfa 100644 (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);
index 1646decd90e79e497b576accc7adea3476520c96..481ec195aeeb9bbbec72757dec652c1b5157809a 100644 (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;
        }