From e081bb3921aefdf773ee4f490c56139d467c3757 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 13 Feb 2017 11:58:52 +0100 Subject: [PATCH] clutter: Add clutter_input_device_is_grouped call/vfunc This will be used to query grouped devices (eg. tablets and pads) https://bugzilla.gnome.org/show_bug.cgi?id=779986 --- clutter/clutter/clutter-device-manager-private.h | 3 +++ clutter/clutter/clutter-input-device.c | 10 ++++++++++ clutter/clutter/clutter-input-device.h | 3 +++ clutter/clutter/evdev/clutter-input-device-evdev.c | 14 ++++++++++++++ clutter/clutter/x11/clutter-input-device-xi2.c | 8 ++++++++ 5 files changed, 38 insertions(+) diff --git a/clutter/clutter/clutter-device-manager-private.h b/clutter/clutter/clutter-device-manager-private.h index 37b2eec6c..57423c41a 100644 --- a/clutter/clutter/clutter-device-manager-private.h +++ b/clutter/clutter/clutter-device-manager-private.h @@ -160,6 +160,9 @@ struct _ClutterInputDeviceClass guint button); gint (* get_group_n_modes) (ClutterInputDevice *device, gint group); + + gboolean (* is_grouped) (ClutterInputDevice *device, + ClutterInputDevice *other_device); }; /* Platform-dependent interface */ diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c index 686e5a804..d8caf0118 100644 --- a/clutter/clutter/clutter-input-device.c +++ b/clutter/clutter/clutter-input-device.c @@ -2266,3 +2266,13 @@ clutter_input_device_set_mapping_mode (ClutterInputDevice *device, device->mapping_mode = mapping; g_object_notify (G_OBJECT (device), "mapping-mode"); } + +gboolean +clutter_input_device_is_grouped (ClutterInputDevice *device, + ClutterInputDevice *other_device) +{ + g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE); + g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (other_device), FALSE); + + return CLUTTER_INPUT_DEVICE_GET_CLASS (device)->is_grouped (device, other_device); +} diff --git a/clutter/clutter/clutter-input-device.h b/clutter/clutter/clutter-input-device.h index f80a48ce1..3961b5027 100644 --- a/clutter/clutter/clutter-input-device.h +++ b/clutter/clutter/clutter-input-device.h @@ -168,6 +168,9 @@ ClutterInputDeviceMapping clutter_input_device_get_mapping_mode (ClutterInputDev CLUTTER_AVAILABLE_IN_ALL void clutter_input_device_set_mapping_mode (ClutterInputDevice *device, ClutterInputDeviceMapping mapping); +CLUTTER_AVAILABLE_IN_ALL +gboolean clutter_input_device_is_grouped (ClutterInputDevice *device, + ClutterInputDevice *other_device); G_END_DECLS diff --git a/clutter/clutter/evdev/clutter-input-device-evdev.c b/clutter/clutter/evdev/clutter-input-device-evdev.c index 0dc578dde..6019d05b4 100644 --- a/clutter/clutter/evdev/clutter-input-device-evdev.c +++ b/clutter/clutter/evdev/clutter-input-device-evdev.c @@ -193,6 +193,19 @@ clutter_input_device_evdev_get_group_n_modes (ClutterInputDevice *device, return libinput_tablet_pad_mode_group_get_num_modes (mode_group); } +static gboolean +clutter_input_device_evdev_is_grouped (ClutterInputDevice *device, + ClutterInputDevice *other_device) +{ + struct libinput_device *libinput_device, *other_libinput_device; + + libinput_device = clutter_evdev_input_device_get_libinput_device (device); + other_libinput_device = clutter_evdev_input_device_get_libinput_device (other_device); + + return libinput_device_get_device_group (libinput_device) == + libinput_device_get_device_group (other_libinput_device); +} + static void clutter_input_device_evdev_class_init (ClutterInputDeviceEvdevClass *klass) { @@ -206,6 +219,7 @@ clutter_input_device_evdev_class_init (ClutterInputDeviceEvdevClass *klass) klass->update_from_tool = clutter_input_device_evdev_update_from_tool; klass->is_mode_switch_button = clutter_input_device_evdev_is_mode_switch_button; klass->get_group_n_modes = clutter_input_device_evdev_get_group_n_modes; + klass->is_grouped = clutter_input_device_evdev_is_grouped; obj_props[PROP_DEVICE_MATRIX] = g_param_spec_boxed ("device-matrix", diff --git a/clutter/clutter/x11/clutter-input-device-xi2.c b/clutter/clutter/x11/clutter-input-device-xi2.c index d6bb87fdf..7fb0e05ad 100644 --- a/clutter/clutter/x11/clutter-input-device-xi2.c +++ b/clutter/clutter/x11/clutter-input-device-xi2.c @@ -80,6 +80,13 @@ clutter_input_device_xi2_keycode_to_evdev (ClutterInputDevice *device, return TRUE; } +static gboolean +clutter_input_device_xi2_is_grouped (ClutterInputDevice *device, + ClutterInputDevice *other_device) +{ + return FALSE; +} + static void clutter_input_device_xi2_class_init (ClutterInputDeviceXI2Class *klass) { @@ -89,6 +96,7 @@ clutter_input_device_xi2_class_init (ClutterInputDeviceXI2Class *klass) gobject_class->constructed = clutter_input_device_xi2_constructed; device_class->keycode_to_evdev = clutter_input_device_xi2_keycode_to_evdev; + device_class->is_grouped = clutter_input_device_xi2_is_grouped; } static void