mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
input-device: Add vendor/product ID properties and getters
This may be useful when trying to identify the device across sessions. https://bugzilla.gnome.org/show_bug.cgi?id=740759
This commit is contained in:
parent
9660b001f7
commit
78fdefcf0c
@ -129,6 +129,9 @@ struct _ClutterInputDevice
|
||||
|
||||
GArray *scroll_info;
|
||||
|
||||
gchar *vendor_id;
|
||||
gchar *product_id;
|
||||
|
||||
guint has_cursor : 1;
|
||||
guint is_enabled : 1;
|
||||
};
|
||||
|
@ -66,6 +66,9 @@ enum
|
||||
|
||||
PROP_N_AXES,
|
||||
|
||||
PROP_VENDOR_ID,
|
||||
PROP_PRODUCT_ID,
|
||||
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@ -82,6 +85,8 @@ clutter_input_device_dispose (GObject *gobject)
|
||||
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (gobject);
|
||||
|
||||
g_clear_pointer (&device->device_name, g_free);
|
||||
g_clear_pointer (&device->vendor_id, g_free);
|
||||
g_clear_pointer (&device->product_id, g_free);
|
||||
|
||||
if (device->associated != NULL)
|
||||
{
|
||||
@ -156,6 +161,14 @@ clutter_input_device_set_property (GObject *gobject,
|
||||
clutter_input_device_set_enabled (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_VENDOR_ID:
|
||||
self->vendor_id = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_PRODUCT_ID:
|
||||
self->product_id = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@ -208,6 +221,14 @@ clutter_input_device_get_property (GObject *gobject,
|
||||
g_value_set_boolean (value, self->is_enabled);
|
||||
break;
|
||||
|
||||
case PROP_VENDOR_ID:
|
||||
g_value_set_string (value, self->vendor_id);
|
||||
break;
|
||||
|
||||
case PROP_PRODUCT_ID:
|
||||
g_value_set_string (value, self->product_id);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@ -357,6 +378,34 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
|
||||
CLUTTER_TYPE_BACKEND,
|
||||
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
/**
|
||||
* ClutterInputDevice:vendor-id:
|
||||
*
|
||||
* Vendor ID of this device.
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
obj_props[PROP_VENDOR_ID] =
|
||||
g_param_spec_string ("vendor-id",
|
||||
P_("Vendor ID"),
|
||||
P_("Vendor ID"),
|
||||
NULL,
|
||||
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
/**
|
||||
* ClutterInputDevice:product-id:
|
||||
*
|
||||
* Product ID of this device.
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
obj_props[PROP_PRODUCT_ID] =
|
||||
g_param_spec_string ("product-id",
|
||||
P_("Product ID"),
|
||||
P_("Product ID"),
|
||||
NULL,
|
||||
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
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;
|
||||
@ -1887,3 +1936,41 @@ clutter_input_device_sequence_get_grabbed_actor (ClutterInputDevice *device,
|
||||
|
||||
return g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_input_device_get_vendor_id:
|
||||
* @device: a slave #ClutterInputDevice
|
||||
*
|
||||
* Gets the vendor ID of this device.
|
||||
*
|
||||
* Returns: the vendor ID
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
const gchar *
|
||||
clutter_input_device_get_vendor_id (ClutterInputDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER, NULL);
|
||||
|
||||
return device->vendor_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_input_device_get_product_id:
|
||||
* @device: a slave #ClutterInputDevice
|
||||
*
|
||||
* Gets the product ID of this device.
|
||||
*
|
||||
* Returns: the product ID
|
||||
*
|
||||
* Since: 1.22
|
||||
*/
|
||||
const gchar *
|
||||
clutter_input_device_get_product_id (ClutterInputDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
||||
g_return_val_if_fail (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER, NULL);
|
||||
|
||||
return device->product_id;
|
||||
}
|
||||
|
@ -135,6 +135,11 @@ gboolean clutter_input_device_keycode_to_evdev (ClutterInputDev
|
||||
guint hardware_keycode,
|
||||
guint *evdev_keycode);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_22
|
||||
const gchar * clutter_input_device_get_vendor_id (ClutterInputDevice *device);
|
||||
CLUTTER_AVAILABLE_IN_1_22
|
||||
const gchar * clutter_input_device_get_product_id (ClutterInputDevice *device);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_INPUT_DEVICE_H__ */
|
||||
|
@ -1201,6 +1201,8 @@ clutter_input_device_get_associated_device
|
||||
clutter_input_device_get_slave_devices
|
||||
clutter_input_device_get_modifier_state
|
||||
clutter_input_device_keycode_to_evdev
|
||||
clutter_input_device_get_vendor_id
|
||||
clutter_input_device_get_product_id
|
||||
|
||||
<SUBSECTION>
|
||||
clutter_input_device_get_n_keys
|
||||
|
Loading…
Reference in New Issue
Block a user