]> git.mdlowis.com Git - proto/labwc.git/commitdiff
session-lock: allow client to update cursor shape
authortokyo4j <hrak1529@gmail.com>
Wed, 29 May 2024 15:53:52 +0000 (00:53 +0900)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Fri, 31 May 2024 02:21:29 +0000 (11:21 +0900)
include/node.h
src/desktop.c
src/session-lock.c

index d0a41c71d27c8ad4ce50b6d6a9ec427e9a5de562..538fc98fedbaee36c2da34e9b2a425a51789c746 100644 (file)
@@ -15,6 +15,7 @@ enum node_descriptor_type {
        LAB_NODE_DESC_XDG_POPUP,
        LAB_NODE_DESC_LAYER_SURFACE,
        LAB_NODE_DESC_LAYER_POPUP,
+       LAB_NODE_DESC_SESSION_LOCK_SURFACE,
        LAB_NODE_DESC_IME_POPUP,
        LAB_NODE_DESC_MENUITEM,
        LAB_NODE_DESC_TREE,
index 58f87a1f1b3de60adb25b1145f04c744540c414a..2c0db207817f537eb3dfcb0ca4caebaedd6ffbeb 100644 (file)
@@ -336,6 +336,7 @@ get_cursor_context(struct server *server)
                                ret.type = LAB_SSD_CLIENT;
                                ret.surface = get_surface_from_layer_node(node);
                                return ret;
+                       case LAB_NODE_DESC_SESSION_LOCK_SURFACE: /* fallthrough */
                        case LAB_NODE_DESC_IME_POPUP:
                                ret.type = LAB_SSD_CLIENT;
                                ret.surface = lab_wlr_surface_from_node(ret.node);
index d9968f089f45b9a5e185414df028bb3909823e8e..72db111fbce3e114fe2081199e1c3809d7ed033d 100644 (file)
@@ -3,6 +3,7 @@
 #include <assert.h>
 #include "common/mem.h"
 #include "labwc.h"
+#include "node.h"
 
 struct session_lock_output {
        struct wlr_scene_tree *tree;
@@ -49,15 +50,31 @@ refocus_output(struct session_lock_output *output)
 }
 
 static void
-handle_surface_map(struct wl_listener *listener, void *data)
+update_focus(void *data)
 {
-       struct session_lock_output *output =
-               wl_container_of(listener, output, surface_map);
+       struct session_lock_output *output = data;
+       cursor_update_focus(output->manager->server);
        if (!output->manager->focused) {
                focus_surface(output->manager, output->surface->surface);
        }
 }
 
+static void
+handle_surface_map(struct wl_listener *listener, void *data)
+{
+       struct session_lock_output *output =
+               wl_container_of(listener, output, surface_map);
+       /*
+        * In order to update cursor shape on map, the call to
+        * cursor_update_focus() should be delayed because only the
+        * role-specific surface commit/map handler has been processed in
+        * wlroots at this moment and get_cursor_context() returns NULL as a
+        * buffer has not been actually attached to the surface.
+        */
+       wl_event_loop_add_idle(
+               output->manager->server->wl_event_loop, update_focus, output);
+}
+
 static void
 handle_surface_destroy(struct wl_listener *listener, void *data)
 {
@@ -103,7 +120,10 @@ handle_new_surface(struct wl_listener *listener, void *data)
 
 found_lock_output:
        lock_output->surface = lock_surface;
-       wlr_scene_subsurface_tree_create(lock_output->tree, lock_surface->surface);
+       struct wlr_scene_tree *surface_tree =
+               wlr_scene_subsurface_tree_create(lock_output->tree, lock_surface->surface);
+       node_descriptor_create(&surface_tree->node,
+               LAB_NODE_DESC_SESSION_LOCK_SURFACE, NULL);
 
        lock_output->surface_destroy.notify = handle_surface_destroy;
        wl_signal_add(&lock_surface->events.destroy, &lock_output->surface_destroy);
@@ -247,6 +267,7 @@ handle_lock_unlock(struct wl_listener *listener, void *data)
        session_lock_destroy(manager);
        manager->locked = false;
        desktop_focus_topmost_view(manager->server);
+       cursor_update_focus(manager->server);
 }
 
 static void