]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: move tablet tool functions into tablet.c
authorJens Peters <jp7677@gmail.com>
Tue, 10 Jun 2025 17:37:17 +0000 (19:37 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sat, 14 Jun 2025 12:45:51 +0000 (13:45 +0100)
Just a big move and a rename of the tablet tool destroy handler.

include/input/tablet-tool.h [deleted file]
include/input/tablet.h
src/input/cursor.c
src/input/meson.build
src/input/tablet-tool.c [deleted file]
src/input/tablet.c

diff --git a/include/input/tablet-tool.h b/include/input/tablet-tool.h
deleted file mode 100644 (file)
index 5ca9404..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef LABWC_TABLET_TOOL_H
-#define LABWC_TABLET_TOOL_H
-
-#include <wayland-server-core.h>
-#include <wlr/types/wlr_tablet_v2.h>
-
-struct seat;
-
-struct drawing_tablet_tool {
-       struct seat *seat;
-       struct wlr_tablet_v2_tablet_tool *tool_v2;
-
-       /*
-        * Force mouse emulation just for a specific tool,
-        * even when global mouse emulation for tablet input
-        * is off.
-        */
-       bool force_mouse_emulation;
-
-       enum motion motion_mode;
-       double x, y, dx, dy;
-       double distance;
-       double pressure;
-       double tilt_x, tilt_y;
-       double rotation;
-       double slider;
-       double wheel_delta;
-       struct {
-               struct wl_listener set_cursor;
-               struct wl_listener destroy;
-       } handlers;
-       struct wl_list link; /* seat.tablet_tools */
-};
-
-void tablet_tool_create(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 8ef465eef7e11946046fa189a170a5caabae7812..55bdd0c906baccef4b13a171b9b7cc762a8735d6 100644 (file)
@@ -9,6 +9,32 @@ struct seat;
 struct wlr_device;
 struct wlr_input_device;
 
+struct drawing_tablet_tool {
+       struct seat *seat;
+       struct wlr_tablet_v2_tablet_tool *tool_v2;
+
+       /*
+        * Force mouse emulation just for a specific tool,
+        * even when global mouse emulation for tablet input
+        * is off.
+        */
+       bool force_mouse_emulation;
+
+       enum motion motion_mode;
+       double x, y, dx, dy;
+       double distance;
+       double pressure;
+       double tilt_x, tilt_y;
+       double rotation;
+       double slider;
+       double wheel_delta;
+       struct {
+               struct wl_listener set_cursor;
+               struct wl_listener destroy;
+       } handlers;
+       struct wl_list link; /* seat.tablet_tools */
+};
+
 struct drawing_tablet {
        struct wlr_input_device *wlr_input_device;
        struct seat *seat;
@@ -23,5 +49,7 @@ struct drawing_tablet {
 void tablet_init(struct seat *seat);
 void tablet_finish(struct seat *seat);
 void tablet_create(struct seat *seat, struct wlr_input_device *wlr_input_device);
+void tablet_tool_create(struct seat *seat, struct wlr_tablet_tool *wlr_tablet_tool);
+bool tablet_tool_has_focused_surface(struct seat *seat);
 
 #endif /* LABWC_TABLET_H */
index 217f6be231967a5b2fe4c9d5b23b94ab3f87249f..c9a224803a74453e88fbcb4f0beb81cc80274840 100644 (file)
@@ -20,7 +20,6 @@
 #include "input/gestures.h"
 #include "input/keyboard.h"
 #include "input/tablet.h"
-#include "input/tablet-tool.h"
 #include "input/touch.h"
 #include "labwc.h"
 #include "layers.h"
index a9a6f5e3d43221742408a3a9369d54bc132d4a7f..4d56f00dea6557832da312a1dbb6ae5a915b8d5b 100644 (file)
@@ -2,7 +2,6 @@ labwc_sources += files(
   'cursor.c',
   'tablet.c',
   'tablet-pad.c',
-  'tablet-tool.c',
   'gestures.c',
   'input.c',
   'keyboard.c',
diff --git a/src/input/tablet-tool.c b/src/input/tablet-tool.c
deleted file mode 100644 (file)
index fcc1e73..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-#include <assert.h>
-#include <stdlib.h>
-#include <wlr/types/wlr_tablet_pad.h>
-#include <wlr/types/wlr_tablet_tool.h>
-#include <wlr/util/log.h>
-#include "common/macros.h"
-#include "common/mem.h"
-#include "config/rcxml.h"
-#include "input/cursor.h"
-#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)
-{
-       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)
-{
-       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);
-}
-
-void
-tablet_tool_create(struct seat *seat,
-               struct wlr_tablet_tool *wlr_tablet_tool)
-{
-       wlr_log(WLR_DEBUG, "setting up tablet tool");
-       struct drawing_tablet_tool *tool = znew(*tool);
-       tool->seat = seat;
-       tool->tool_v2 =
-               wlr_tablet_tool_create(seat->server->tablet_manager,
-                       seat->seat, wlr_tablet_tool);
-       wlr_tablet_tool->data = tool;
-       wlr_log(WLR_INFO, "tablet tool capabilities:%s%s%s%s%s%s",
-               wlr_tablet_tool->tilt ? " tilt" : "",
-               wlr_tablet_tool->pressure ? " pressure" : "",
-               wlr_tablet_tool->distance ? " distance" : "",
-               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);
-       wl_list_insert(&seat->tablet_tools, &tool->link);
-}
index 47e6972320a6f9cff1433f6e80c5c5579ada1d07..49d2aaebb4e64010d9e4bed1630b189c93f92888 100644 (file)
 #include "config/mousebind.h"
 #include "input/cursor.h"
 #include "input/tablet.h"
-#include "input/tablet-tool.h"
 #include "input/tablet-pad.h"
 #include "labwc.h"
 #include "idle.h"
 #include "action.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)
+{
+       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_tablet_tool_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);
+}
+
+void
+tablet_tool_create(struct seat *seat,
+               struct wlr_tablet_tool *wlr_tablet_tool)
+{
+       wlr_log(WLR_DEBUG, "setting up tablet tool");
+       struct drawing_tablet_tool *tool = znew(*tool);
+       tool->seat = seat;
+       tool->tool_v2 =
+               wlr_tablet_tool_create(seat->server->tablet_manager,
+                       seat->seat, wlr_tablet_tool);
+       wlr_tablet_tool->data = tool;
+       wlr_log(WLR_INFO, "tablet tool capabilities:%s%s%s%s%s%s",
+               wlr_tablet_tool->tilt ? " tilt" : "",
+               wlr_tablet_tool->pressure ? " pressure" : "",
+               wlr_tablet_tool->distance ? " distance" : "",
+               wlr_tablet_tool->rotation ? " rotation" : "",
+               wlr_tablet_tool->slider ? " slider" : "",
+               wlr_tablet_tool->wheel ? " wheel" : "");
+       CONNECT_SIGNAL(tool->tool_v2, &tool->handlers, set_cursor);
+       wl_signal_add(&wlr_tablet_tool->events.destroy, &tool->handlers.destroy);
+       tool->handlers.destroy.notify = handle_tablet_tool_destroy;
+
+       wl_list_insert(&seat->tablet_tools, &tool->link);
+}
+
 static enum motion
 tool_motion_mode(enum motion motion, struct wlr_tablet_tool *tool)
 {