]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: handle tablet tool cursor requests
authorJens Peters <jp7677@gmail.com>
Sat, 20 Apr 2024 09:46:10 +0000 (11:46 +0200)
committerConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 27 May 2024 20:40:50 +0000 (22:40 +0200)
Similar to cursor requests for pointers.

src/input/tablet-tool.c

index ee8667d6b1657bed0537559b38fd6c8b492c8206..250c3b9104c49f77890a1e481c49e7ae886ba9a3 100644 (file)
 #include "input/tablet-tool.h"
 #include "labwc.h"
 
+static void
+handle_set_cursor(struct wl_listener *listener, void *data)
+{
+       struct drawing_tablet_tool *tool =
+               wl_container_of(listener, tool, handlers.set_cursor);
+       struct wlr_tablet_v2_event_cursor *ev = data;
+
+       struct seat *seat = tool->seat;
+       struct wlr_seat_client *focused_client =
+               seat->seat->pointer_state.focused_client;
+
+       if (seat->server->input_mode != LAB_INPUT_STATE_PASSTHROUGH) {
+               return;
+       }
+
+       if (ev->seat_client != focused_client) {
+               return;
+       }
+
+       wlr_cursor_set_surface(seat->cursor, ev->surface,
+               ev->hotspot_x, ev->hotspot_y);
+}
+
 static void
 handle_destroy(struct wl_listener *listener, void *data)
 {
@@ -40,5 +63,6 @@ tablet_tool_init(struct seat *seat,
                wlr_tablet_tool->rotation ? " rotation" : "",
                wlr_tablet_tool->slider ? " slider" : "",
                wlr_tablet_tool->wheel ? " wheel" : "");
+       CONNECT_SIGNAL(tool->tool_v2, &tool->handlers, set_cursor);
        CONNECT_SIGNAL(wlr_tablet_tool, &tool->handlers, destroy);
 }