diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2020-11-19 00:47:04 +0100 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2020-11-27 15:14:33 +0000 |
commit | e772f62ea7d265cce1e7d5ad18dc82e6481ba418 (patch) | |
tree | 54d5b535d99d7beb0682f10a399b0d27edf1447b /src | |
parent | be9c531ab94dfbbe66b691358d8fa62452363e18 (diff) | |
download | mutter-e772f62ea7d265cce1e7d5ad18dc82e6481ba418.tar.gz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/backends/native/meta-input-device-tool-native.c | 22 | ||||
-rw-r--r-- | src/backends/x11/meta-input-device-tool-x11.c | 11 | ||||
-rw-r--r-- | src/wayland/meta-wayland-tablet-tool.c | 76 |
3 files changed, 49 insertions, 60 deletions
diff --git a/src/backends/native/meta-input-device-tool-native.c b/src/backends/native/meta-input-device-tool-native.c index 8b540afbb..dc47b81a7 100644 --- a/src/backends/native/meta-input-device-tool-native.c +++ b/src/backends/native/meta-input-device-tool-native.c @@ -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); diff --git a/src/backends/x11/meta-input-device-tool-x11.c b/src/backends/x11/meta-input-device-tool-x11.c index 0632fea5a..bec4d1fad 100644 --- a/src/backends/x11/meta-input-device-tool-x11.c +++ b/src/backends/x11/meta-input-device-tool-x11.c @@ -38,8 +38,19 @@ ClutterInputDeviceTool * meta_input_device_tool_x11_new (guint serial, ClutterInputDeviceToolType type) { + ClutterInputAxisFlags axes = + CLUTTER_INPUT_AXIS_FLAG_PRESSURE | + CLUTTER_INPUT_AXIS_FLAG_DISTANCE | + CLUTTER_INPUT_AXIS_FLAG_XTILT | + CLUTTER_INPUT_AXIS_FLAG_YTILT | + CLUTTER_INPUT_AXIS_FLAG_WHEEL | + CLUTTER_INPUT_AXIS_FLAG_DISTANCE | + CLUTTER_INPUT_AXIS_FLAG_ROTATION | + CLUTTER_INPUT_AXIS_FLAG_SLIDER; + return g_object_new (META_TYPE_INPUT_DEVICE_TOOL_X11, "type", type, "serial", serial, + "axes", axes, NULL); } diff --git a/src/wayland/meta-wayland-tablet-tool.c b/src/wayland/meta-wayland-tablet-tool.c index 8ff2accb2..8c1984f62 100644 --- a/src/wayland/meta-wayland-tablet-tool.c +++ b/src/wayland/meta-wayland-tablet-tool.c @@ -137,45 +137,6 @@ meta_wayland_tablet_tool_set_cursor_surface (MetaWaylandTabletTool *tool, meta_wayland_tablet_tool_update_cursor_surface (tool); } -static uint32_t -input_device_get_capabilities (ClutterInputDevice *device) -{ - ClutterInputAxis axis; - guint32 capabilities = 0, i; - - for (i = 0; i < clutter_input_device_get_n_axes (device); i++) - { - axis = clutter_input_device_get_axis (device, i); - - switch (axis) - { - case CLUTTER_INPUT_AXIS_PRESSURE: - capabilities |= 1 << ZWP_TABLET_TOOL_V2_CAPABILITY_PRESSURE; - break; - case CLUTTER_INPUT_AXIS_DISTANCE: - capabilities |= 1 << ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE; - break; - case CLUTTER_INPUT_AXIS_XTILT: - case CLUTTER_INPUT_AXIS_YTILT: - capabilities |= 1 << ZWP_TABLET_TOOL_V2_CAPABILITY_TILT; - break; - case CLUTTER_INPUT_AXIS_ROTATION: - capabilities |= 1 << ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION; - break; - case CLUTTER_INPUT_AXIS_WHEEL: - capabilities |= 1 << ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL; - break; - case CLUTTER_INPUT_AXIS_SLIDER: - capabilities |= 1 << ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER; - break; - default: - break; - } - } - - return capabilities; -} - static enum zwp_tablet_tool_v2_type input_device_tool_get_type (ClutterInputDeviceTool *device_tool) { @@ -210,26 +171,26 @@ static void meta_wayland_tablet_tool_notify_capabilities (MetaWaylandTabletTool *tool, struct wl_resource *resource) { - uint32_t capabilities; + ClutterInputAxisFlags axes; - capabilities = input_device_get_capabilities (tool->device); + axes = clutter_input_device_tool_get_axes (tool->device_tool); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_PRESSURE)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_PRESSURE) zwp_tablet_tool_v2_send_capability (resource, ZWP_TABLET_TOOL_V2_CAPABILITY_PRESSURE); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_DISTANCE) zwp_tablet_tool_v2_send_capability (resource, ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_TILT)) + if (axes & (CLUTTER_INPUT_AXIS_FLAG_XTILT | CLUTTER_INPUT_AXIS_FLAG_YTILT)) zwp_tablet_tool_v2_send_capability (resource, ZWP_TABLET_TOOL_V2_CAPABILITY_TILT); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_ROTATION) zwp_tablet_tool_v2_send_capability (resource, ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_SLIDER) zwp_tablet_tool_v2_send_capability (resource, ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_WHEEL) zwp_tablet_tool_v2_send_capability (resource, ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL); } @@ -842,26 +803,21 @@ static void broadcast_axes (MetaWaylandTabletTool *tool, const ClutterEvent *event) { - ClutterInputDevice *device; - guint32 capabilities; - - if (!event->motion.axes) - return; + ClutterInputAxisFlags axes; - device = clutter_event_get_source_device (event); - capabilities = input_device_get_capabilities (device); + axes = clutter_input_device_tool_get_axes (tool->device_tool); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_PRESSURE)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_PRESSURE) broadcast_axis (tool, event, CLUTTER_INPUT_AXIS_PRESSURE); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_DISTANCE) broadcast_axis (tool, event, CLUTTER_INPUT_AXIS_DISTANCE); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_TILT)) + if (axes & (CLUTTER_INPUT_AXIS_FLAG_XTILT | CLUTTER_INPUT_AXIS_FLAG_YTILT)) broadcast_tilt (tool, event); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_ROTATION) broadcast_rotation (tool, event); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_SLIDER) broadcast_axis (tool, event, CLUTTER_INPUT_AXIS_SLIDER); - if (capabilities & (1 << ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL)) + if (axes & CLUTTER_INPUT_AXIS_FLAG_WHEEL) broadcast_wheel (tool, event); } |