diff --git a/clutter/clutter/evdev/clutter-input-device-evdev.c b/clutter/clutter/evdev/clutter-input-device-evdev.c index 6019d05b4..cb4340a8f 100644 --- a/clutter/clutter/evdev/clutter-input-device-evdev.c +++ b/clutter/clutter/evdev/clutter-input-device-evdev.c @@ -163,6 +163,9 @@ clutter_input_device_evdev_update_from_tool (ClutterInputDevice *device, if (libinput_tablet_tool_has_slider (evdev_tool->tool)) _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_SLIDER, -1, 1, 0); + if (libinput_tablet_tool_has_wheel (evdev_tool->tool)) + _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_WHEEL, -180, 180, 0); + g_object_thaw_notify (G_OBJECT (device)); } diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c index 51f8fc949..45b25bfb5 100644 --- a/src/wayland/meta-wayland-tablet-tool.c +++ b/src/wayland/meta-wayland-tablet-tool.c @@ -800,6 +800,38 @@ broadcast_rotation (MetaWaylandTabletTool *tool, } } +static void +broadcast_wheel (MetaWaylandTabletTool *tool, + const ClutterEvent *event) +{ + struct wl_resource *resource; + ClutterInputDevice *source; + gdouble angle; + gint32 clicks = 0; + + source = clutter_event_get_source_device (event); + + if (!clutter_input_device_get_axis_value (source, event->motion.axes, + CLUTTER_INPUT_AXIS_WHEEL, + &angle)) + return; + + /* FIXME: Perform proper angle-to-clicks accumulation elsewhere */ + if (angle > 0.01) + clicks = 1; + else if (angle < -0.01) + clicks = -1; + else + return; + + wl_resource_for_each (resource, &tool->focus_resource_list) + { + zwp_tablet_tool_v2_send_wheel (resource, + wl_fixed_from_double (angle), + clicks); + } +} + static void broadcast_axes (MetaWaylandTabletTool *tool, const ClutterEvent *event) @@ -823,8 +855,8 @@ broadcast_axes (MetaWaylandTabletTool *tool, broadcast_rotation (tool, event); if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER)) broadcast_axis (tool, event, CLUTTER_INPUT_AXIS_SLIDER); - - /* FIXME: Missing wp_tablet_tool.wheel */ + if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL)) + broadcast_wheel (tool, event); } static void