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
This commit is contained in:
Carlos Garnacho 2017-02-13 11:58:52 +01:00
parent ad24967d78
commit e081bb3921
5 changed files with 38 additions and 0 deletions

View File

@ -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 */

View File

@ -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);
}

View File

@ -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

View File

@ -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",

View File

@ -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