[mutter/wip/carlosg/device-capabilities: 1/5] clutter: Add compatibility code to get input capabilities from device type
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/device-capabilities: 1/5] clutter: Add compatibility code to get input capabilities from device type
- Date: Thu, 10 Mar 2022 10:25:00 +0000 (UTC)
commit 73f2d0696119dc8fbc5d33fbaaba8cb7cef0d819
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Mar 8 17:12:42 2022 +0100
clutter: Add compatibility code to get input capabilities from device type
We not just have X11 devices, but also virtual devices on both backends.
In the mean time, keep these working on top of a ClutterInputDeviceType,
but transform that into capabilities on device construction so users can
rely on the new flagset.
clutter/clutter/clutter-input-device.c | 48 ++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
---
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index c3fed10fbd..8b99846ec0 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -104,6 +104,53 @@ struct _ClutterInputDevicePrivate
G_DEFINE_TYPE_WITH_PRIVATE (ClutterInputDevice, clutter_input_device, G_TYPE_OBJECT);
+static void
+clutter_input_device_constructed (GObject *gobject)
+{
+ ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (gobject);
+ ClutterInputDevicePrivate *priv =
+ clutter_input_device_get_instance_private (device);
+
+ if (priv->capabilities == 0)
+ {
+ ClutterInputCapabilities capabilities = 0;
+
+ switch (priv->device_type)
+ {
+ case CLUTTER_POINTER_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_POINTER;
+ break;
+ case CLUTTER_KEYBOARD_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_KEYBOARD;
+ break;
+ case CLUTTER_TOUCHPAD_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_POINTER |
+ CLUTTER_INPUT_CAPABILITY_TOUCHPAD;
+ break;
+ case CLUTTER_TOUCHSCREEN_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_TOUCH;
+ break;
+ case CLUTTER_TABLET_DEVICE:
+ case CLUTTER_PEN_DEVICE:
+ case CLUTTER_ERASER_DEVICE:
+ case CLUTTER_CURSOR_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_TABLET_TOOL;
+ break;
+ case CLUTTER_PAD_DEVICE:
+ capabilities = CLUTTER_INPUT_CAPABILITY_TABLET_PAD;
+ break;
+ case CLUTTER_EXTENSION_DEVICE:
+ case CLUTTER_JOYSTICK_DEVICE:
+ break;
+ case CLUTTER_N_DEVICE_TYPES:
+ g_assert_not_reached ();
+ break;
+ }
+
+ priv->capabilities = capabilities;
+ }
+}
+
static void
clutter_input_device_dispose (GObject *gobject)
{
@@ -437,6 +484,7 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
NULL,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ gobject_class->constructed = clutter_input_device_constructed;
gobject_class->dispose = clutter_input_device_dispose;
gobject_class->set_property = clutter_input_device_set_property;
gobject_class->get_property = clutter_input_device_get_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]