fix: correct set_cursor for tablet tool

This commit is contained in:
werapi 2026-03-20 07:19:16 +01:00
parent ba71bc1de7
commit 95544b82b2

View file

@ -11,6 +11,7 @@ static void tabletpadattach(struct wl_listener *listener, void *data);
static void destroytabletsurfacenotify(struct wl_listener *listener, static void destroytabletsurfacenotify(struct wl_listener *listener,
void *data); void *data);
static void destroytablettool(struct wl_listener *listener, void *data); static void destroytablettool(struct wl_listener *listener, void *data);
static void tablettoolsetcursor(struct wl_listener *listener, void *data);
static void tablettoolproximity(struct wl_listener *listener, void *data); static void tablettoolproximity(struct wl_listener *listener, void *data);
static void tablettoolaxis(struct wl_listener *listener, void *data); static void tablettoolaxis(struct wl_listener *listener, void *data);
@ -31,6 +32,7 @@ struct TabletTool {
struct wlr_surface *curr_surface; struct wlr_surface *curr_surface;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener surface_destroy; struct wl_listener surface_destroy;
struct wl_listener set_cursor;
double tilt_x, tilt_y; double tilt_x, tilt_y;
}; };
@ -208,11 +210,29 @@ void destroytablettool(struct wl_listener *listener, void *data) {
if (tool->curr_surface) if (tool->curr_surface)
wl_list_remove(&tool->surface_destroy.link); wl_list_remove(&tool->surface_destroy.link);
wl_list_remove(&tool->set_cursor.link);
wl_list_remove(&listener->link); wl_list_remove(&listener->link);
free(tool); free(tool);
} }
static void tablettoolsetcursor(struct wl_listener *listener, void *data) {
struct TabletTool *tool = wl_container_of(listener, tool, set_cursor);
struct wlr_tablet_v2_event_cursor *event = data;
struct wlr_seat_client *focused_client = NULL;
if (tool->tool_v2->focused_surface) {
focused_client = wlr_seat_client_for_wl_client(
seat,
wl_resource_get_client(tool->tool_v2->focused_surface->resource));
}
if (focused_client != event->seat_client)
return;
wlr_cursor_set_surface(cursor, event->surface, event->hotspot_x,
event->hotspot_y);
}
void tablettoolmotion(struct TabletTool *tool, bool change_x, bool change_y, void tablettoolmotion(struct TabletTool *tool, bool change_x, bool change_y,
double x, double y, double dx, double dy) { double x, double y, double dx, double dy) {
struct wlr_surface *surface = NULL; struct wlr_surface *surface = NULL;
@ -304,10 +324,11 @@ void tablettoolproximity(struct wl_listener *listener, void *data) {
tool->tool_v2 = wlr_tablet_tool_create(tablet_mgr, seat, wlr_tool); tool->tool_v2 = wlr_tablet_tool_create(tablet_mgr, seat, wlr_tool);
tool->surface_destroy.notify = destroytabletsurfacenotify; tool->surface_destroy.notify = destroytabletsurfacenotify;
tool->destroy.notify = destroytablettool; tool->destroy.notify = destroytablettool;
tool->set_cursor.notify = tablettoolsetcursor;
tool->tablet = event->tablet->data; tool->tablet = event->tablet->data;
wlr_tool->data = tool; wlr_tool->data = tool;
wl_signal_add(&tool->tool_v2->wlr_tool->events.destroy, &tool->destroy); wl_signal_add(&tool->tool_v2->wlr_tool->events.destroy, &tool->destroy);
wl_signal_add(&tool->tool_v2->events.set_cursor, &request_cursor); wl_signal_add(&tool->tool_v2->events.set_cursor, &tool->set_cursor);
} }
switch (event->state) { switch (event->state) {