]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: prevent cursor notifications from pointer and tablet tool
authorJens Peters <jp7677@gmail.com>
Tue, 28 May 2024 18:50:05 +0000 (20:50 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Fri, 31 May 2024 14:59:43 +0000 (16:59 +0200)
... at the same time. Omit cursor notifications from
a pointer when a tablet tool (stylus/pen) is in
proximity. We expect to get cursor notifications
from the tablet tool instead.

include/input/tablet-tool.h
include/labwc.h
src/input/cursor.c
src/input/tablet-tool.c
src/seat.c

index 8e578a41e31b4ffdf08276cfdb28486b19161136..6da983c40f072a62fdd6e364195f400786914566 100644 (file)
@@ -14,6 +14,7 @@ struct drawing_tablet_tool {
                struct wl_listener set_cursor;
                struct wl_listener destroy;
        } handlers;
+       struct wl_list link; /* seat.tablet_tools */
 };
 
 void tablet_tool_init(struct seat *seat,
index a47b3a39d08c0a686c1d00bb30e8c75850c67247..419a5ee0811a73a2222385feebaec259f4d33e4a 100644 (file)
@@ -193,6 +193,8 @@ struct seat {
        struct wl_listener touch_motion;
        struct wl_listener touch_frame;
 
+       struct wl_list tablet_tools;
+
        struct wl_listener constraint_commit;
        struct wl_listener pressed_surface_destroy;
 
index dfd13038a482c8d983f525ea157ef114a0003feb..e5a214b70b597a37df132cc90f4ba372ec554750 100644 (file)
@@ -17,6 +17,7 @@
 #include "idle.h"
 #include "input/gestures.h"
 #include "input/touch.h"
+#include "input/tablet-tool.h"
 #include "labwc.h"
 #include "layers.h"
 #include "menu/menu.h"
@@ -140,6 +141,22 @@ request_cursor_notify(struct wl_listener *listener, void *data)
                return;
        }
 
+       /*
+        * Omit cursor notifications from a pointer when a tablet
+        * tool (stylus/pen) is in proximity. We expect to get cursor
+        * notifications from the tablet tool instead.
+        * Receiving cursor notifications from pointer and tablet tool at
+        * the same time is a side effect of also setting pointer focus
+        * when a tablet tool enters proximity on a tablet-capable surface.
+        * See also `notify_motion()` in `input/tablet.c`.
+        */
+       struct drawing_tablet_tool *tool;
+       wl_list_for_each(tool, &seat->tablet_tools, link) {
+               if (tool->tool_v2->focused_surface) {
+                       return;
+               }
+       }
+
        /*
         * This event is raised by the seat when a client provides a cursor
         * image
index 250c3b9104c49f77890a1e481c49e7ae886ba9a3..7c7faac208a9229db7b9656a2f3db23837193e8b 100644 (file)
@@ -40,6 +40,7 @@ handle_destroy(struct wl_listener *listener, void *data)
        struct drawing_tablet_tool *tool =
                wl_container_of(listener, tool, handlers.destroy);
 
+       wl_list_remove(&tool->link);
        wl_list_remove(&tool->handlers.set_cursor.link);
        wl_list_remove(&tool->handlers.destroy.link);
        free(tool);
@@ -65,4 +66,5 @@ tablet_tool_init(struct seat *seat,
                wlr_tablet_tool->wheel ? " wheel" : "");
        CONNECT_SIGNAL(tool->tool_v2, &tool->handlers, set_cursor);
        CONNECT_SIGNAL(wlr_tablet_tool, &tool->handlers, destroy);
+       wl_list_insert(&seat->tablet_tools, &tool->link);
 }
index e850694c1a8e15d78af4d09fe9592f7e75cbe598..5b4afe59a12d53fe582b42f01c664948038cb6c1 100644 (file)
@@ -553,6 +553,8 @@ seat_init(struct server *server)
        }
        wlr_cursor_attach_output_layout(seat->cursor, server->output_layout);
 
+       wl_list_init(&seat->tablet_tools);
+
        input_handlers_init(seat);
 }