mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
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
This commit is contained in:
parent
f852d2b0eb
commit
4d8cb5408b
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user