clutter: Make axes part of the device tool

This info can be construct-only there, as opposed to devices.
Move this info to tools, so we can drop it from devices.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho
2020-11-19 00:47:04 +01:00
committed by Marge Bot
parent be9c531ab9
commit e772f62ea7
6 changed files with 93 additions and 60 deletions

View File

@ -49,6 +49,27 @@ meta_input_device_tool_native_init (MetaInputDeviceToolNative *tool)
tool->button_map = g_hash_table_new (NULL, NULL);
}
static ClutterInputAxisFlags
translate_axes (struct libinput_tablet_tool *tool)
{
ClutterInputAxisFlags axes = 0;
if (libinput_tablet_tool_has_pressure (tool))
axes |= CLUTTER_INPUT_AXIS_FLAG_PRESSURE;
if (libinput_tablet_tool_has_distance (tool))
axes |= CLUTTER_INPUT_AXIS_FLAG_DISTANCE;
if (libinput_tablet_tool_has_rotation (tool))
axes |= CLUTTER_INPUT_AXIS_FLAG_ROTATION;
if (libinput_tablet_tool_has_slider (tool))
axes |= CLUTTER_INPUT_AXIS_FLAG_SLIDER;
if (libinput_tablet_tool_has_wheel (tool))
axes |= CLUTTER_INPUT_AXIS_FLAG_WHEEL;
if (libinput_tablet_tool_has_tilt (tool))
axes |= CLUTTER_INPUT_AXIS_FLAG_XTILT | CLUTTER_INPUT_AXIS_FLAG_YTILT;
return axes;
}
ClutterInputDeviceTool *
meta_input_device_tool_native_new (struct libinput_tablet_tool *tool,
uint64_t serial,
@ -60,6 +81,7 @@ meta_input_device_tool_native_new (struct libinput_tablet_tool *tool,
"type", type,
"serial", serial,
"id", libinput_tablet_tool_get_tool_id (tool),
"axes", translate_axes (tool),
NULL);
evdev_tool->tool = libinput_tablet_tool_ref (tool);