summaryrefslogtreecommitdiff
path: root/src/wayland
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2017-06-12 15:25:10 -0700
committerCarlos Garnacho <carlosg@gnome.org>2017-07-17 21:22:15 +0200
commit4d8cb5408b439ae5260faa53c670e1fc531bd302 (patch)
treea5a3dd108aa03db1b4915ec7da16ae8604ff516d /src/wayland
parentf852d2b0eb98cdd6497a627bcf48f9f9db944d0b (diff)
downloadmutter-4d8cb5408b439ae5260faa53c670e1fc531bd302.tar.gz
wayland: Provide basic tablet wheel event support
Adds basic support for the "wheel" event from the Wayland tablet protocol. Ideally we would accumulate the angle and report a wheel event with an appropriate value for "clicks". We can get away with a much cruder method for the time being, however, since no Wacom tablet puck actually provides a smooth scrollwheel. Checking whether the angle in CLUTTER_INPUT_AXIS_WHEEL exceeds a nominally-small threshold is sufficient to determine that the wheel has advanced by at least one physical click. https://bugzilla.gnome.org/show_bug.cgi?id=783716
Diffstat (limited to 'src/wayland')
-rw-r--r--src/wayland/meta-wayland-tablet-tool.c36
1 files changed, 34 insertions, 2 deletions
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
@@ -801,6 +801,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