]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: ignore not supported tablet tools
authorJens Peters <jp7677@gmail.com>
Tue, 7 May 2024 17:35:44 +0000 (19:35 +0200)
committerJohan Malm <johanmalm@users.noreply.github.com>
Sun, 19 May 2024 20:21:52 +0000 (21:21 +0100)
We currently only support cursor emulation
for absolute motion, thus ignore tools/pens
that use relative motion.

Add a log statement on proximity-in to give
some feedback.

include/input/tablet.h
src/input/tablet.c

index d0678c065aa2fc1a682cceea5834078f0a3249bd..b97ddb0d320a4d44cf832a2cb845e237cf59c08f 100644 (file)
@@ -13,11 +13,11 @@ struct drawing_tablet {
        struct wlr_tablet *tablet;
        double x, y;
        struct {
+               struct wl_listener proximity;
                struct wl_listener axis;
                struct wl_listener tip;
                struct wl_listener button;
                struct wl_listener destroy;
-               // no interest in proximity events
        } handlers;
 };
 
index e795cdae75677018e9b3e9143d0fd98a05d10cd0..2d0d68826992cc8c29135d9379c4eb5e7ce75669 100644 (file)
 #include "input/cursor.h"
 #include "input/tablet.h"
 
+static bool
+tool_supports_absolute_motion(struct wlr_tablet_tool *tool)
+{
+       switch (tool->type) {
+       case WLR_TABLET_TOOL_TYPE_MOUSE:
+       case WLR_TABLET_TOOL_TYPE_LENS:
+               return false;
+       default:
+               return true;
+       }
+}
+
 static void
 adjust_for_tablet_area(double tablet_width, double tablet_height,
                struct wlr_fbox box, double *x, double *y)
@@ -63,11 +75,28 @@ adjust_for_rotation(enum rotation rotation, double *x, double *y)
        }
 }
 
+static void
+handle_proximity(struct wl_listener *listener, void *data)
+{
+       struct wlr_tablet_tool_proximity_event *ev = data;
+
+       if (!tool_supports_absolute_motion(ev->tool)) {
+               if (ev->state == WLR_TABLET_TOOL_PROXIMITY_IN) {
+                       wlr_log(WLR_INFO, "ignoring not supporting tablet tool");
+               }
+       }
+}
+
 static void
 handle_axis(struct wl_listener *listener, void *data)
 {
        struct wlr_tablet_tool_axis_event *ev = data;
        struct drawing_tablet *tablet = ev->tablet->data;
+
+       if (!tool_supports_absolute_motion(ev->tool)) {
+               return;
+       }
+
        if (ev->updated_axes & (WLR_TABLET_TOOL_AXIS_X | WLR_TABLET_TOOL_AXIS_Y)) {
                if (ev->updated_axes & WLR_TABLET_TOOL_AXIS_X) {
                        tablet->x = ev->x;
@@ -127,6 +156,7 @@ handle_destroy(struct wl_listener *listener, void *data)
 
        wl_list_remove(&tablet->handlers.tip.link);
        wl_list_remove(&tablet->handlers.button.link);
+       wl_list_remove(&tablet->handlers.proximity.link);
        wl_list_remove(&tablet->handlers.axis.link);
        wl_list_remove(&tablet->handlers.destroy.link);
        free(tablet);
@@ -145,6 +175,7 @@ tablet_init(struct seat *seat, struct wlr_input_device *wlr_device)
        wlr_log(WLR_INFO, "tablet dimensions: %.2fmm x %.2fmm",
                tablet->tablet->width_mm, tablet->tablet->height_mm);
        CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, axis);
+       CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, proximity);
        CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, tip);
        CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, button);
        CONNECT_SIGNAL(wlr_device, &tablet->handlers, destroy);