]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: extract function
authorJens Peters <jp7677@gmail.com>
Tue, 4 Jun 2024 18:11:32 +0000 (20:11 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 8 Jun 2024 21:33:00 +0000 (22:33 +0100)
include/input/tablet-tool.h
src/input/cursor.c
src/input/tablet-tool.c

index 6da983c40f072a62fdd6e364195f400786914566..8f7b589df1bdab55238f5c88c1966511c2f1095d 100644 (file)
@@ -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 */
index 4c0015d3d8b85bc87fc575f67c0c017c07cbeebe..975a295e00959d087c641002b4f3e8ad456f71dd 100644 (file)
@@ -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;
        }
 
        /*
index 7c7faac208a9229db7b9656a2f3db23837193e8b..3e36f5b07e03f4e81513c31d4237021c001e1d07 100644 (file)
 #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)
 {