From ebe81ac5917c6a00d1e15f72ab884aac1a6de917 Mon Sep 17 00:00:00 2001 From: Jens Peters Date: Tue, 4 Jun 2024 20:11:32 +0200 Subject: [PATCH] input: extract function --- include/input/tablet-tool.h | 1 + src/input/cursor.c | 8 +++----- src/input/tablet-tool.c | 13 +++++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/input/tablet-tool.h b/include/input/tablet-tool.h index 6da983c4..8f7b589d 100644 --- a/include/input/tablet-tool.h +++ b/include/input/tablet-tool.h @@ -19,5 +19,6 @@ struct drawing_tablet_tool { void tablet_tool_init(struct seat *seat, struct wlr_tablet_tool *wlr_tablet_tool); +bool tablet_tool_has_focused_surface(struct seat *seat); #endif /* LABWC_TABLET_TOOL_H */ diff --git a/src/input/cursor.c b/src/input/cursor.c index 4c0015d3..975a295e 100644 --- a/src/input/cursor.c +++ b/src/input/cursor.c @@ -18,6 +18,7 @@ #include "input/gestures.h" #include "input/touch.h" #include "input/tablet-tool.h" +#include "input/tablet-pad.h" #include "labwc.h" #include "layers.h" #include "menu/menu.h" @@ -150,11 +151,8 @@ request_cursor_notify(struct wl_listener *listener, void *data) * 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; - } + if (tablet_tool_has_focused_surface(seat)) { + return; } /* diff --git a/src/input/tablet-tool.c b/src/input/tablet-tool.c index 7c7faac2..3e36f5b0 100644 --- a/src/input/tablet-tool.c +++ b/src/input/tablet-tool.c @@ -11,6 +11,19 @@ #include "input/tablet-tool.h" #include "labwc.h" +bool +tablet_tool_has_focused_surface(struct seat *seat) +{ + struct drawing_tablet_tool *tool; + wl_list_for_each(tool, &seat->tablet_tools, link) { + if (tool->tool_v2->focused_surface) { + return true; + } + } + + return false; +} + static void handle_set_cursor(struct wl_listener *listener, void *data) { -- 2.52.0