]> git.mdlowis.com Git - proto/labwc.git/commitdiff
input: emulate cursor axis for tablet tool mouse
authorJens Peters <jp7677@gmail.com>
Fri, 6 Jun 2025 05:14:38 +0000 (07:14 +0200)
committerHiroaki Yamamoto <hrak1529@gmail.com>
Sat, 7 Jun 2025 20:31:23 +0000 (05:31 +0900)
We only have to deal with non-high-res mouses, so we can
emulate it even without having delta_discrete being
exposed by wlroots.

src/input/tablet.c

index 314e5e46de6e896e9bb8f17b622ee30543ee16ae..bc09a1acbf86b3cc52e23874e5f59f928e45a7f0 100644 (file)
@@ -439,6 +439,21 @@ handle_tablet_tool_axis(struct wl_listener *listener, void *data)
                                break;
                        }
                }
+               if (ev->updated_axes & WLR_TABLET_TOOL_AXIS_WHEEL) {
+                       /*
+                        * libinput reports delta_discrete for tablet tool mouses,
+                        * but unfortunately wlroots doesn't expose it. That said,
+                        * based on the libinput source (tablet_device_has_axis()),
+                        * we only have to deal with non-high-res mouses here, so
+                        * it is relatively safe to set a fixed value.
+                        */
+                       int delta_discrete = tablet->wheel_delta >= 0 ? 1 : -1;
+                       cursor_emulate_axis(tablet->seat, &ev->tablet->base,
+                               WL_POINTER_AXIS_VERTICAL_SCROLL,
+                               tablet->wheel_delta,
+                               WLR_POINTER_AXIS_DISCRETE_STEP * delta_discrete,
+                               WL_POINTER_AXIS_SOURCE_WHEEL, ev->time_msec);
+               }
        }
 }