diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2015-01-27 21:35:40 +0000 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2016-04-06 15:43:29 +0200 |
commit | 0f962f107576ceb8adf697c0598fdeed51882e0a (patch) | |
tree | e81de2198d244e0e3474e90d8ee52c304fc38ace /gdk/gdkdevice.c | |
parent | 32d7ba76b3642aefe83d183464a762a1ed152f19 (diff) | |
download | gtk+-0f962f107576ceb8adf697c0598fdeed51882e0a.tar.gz |
device: Add gdk_device_get_axes(), and ::axes property
This returns a GdkAxisFlags, holding the axes currently available
through this device.
Diffstat (limited to 'gdk/gdkdevice.c')
-rw-r--r-- | gdk/gdkdevice.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index 3edaa526f0..0ede56cd43 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -92,6 +92,7 @@ enum { PROP_PRODUCT_ID, PROP_SEAT, PROP_NUM_TOUCHES, + PROP_AXES, LAST_PROP }; @@ -305,6 +306,19 @@ gdk_device_class_init (GdkDeviceClass *klass) 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + /** + * GdkDevice:axes: + * + * The axes currently available for this device. + * + * Since: 3.22 + */ + device_props[PROP_AXES] = + g_param_spec_flags ("axes", + P_("Axes"), + P_("Axes"), + GDK_TYPE_AXIS_FLAGS, 0, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, LAST_PROP, device_props); @@ -477,6 +491,9 @@ gdk_device_get_property (GObject *object, case PROP_NUM_TOUCHES: g_value_set_uint (value, device->num_touches); break; + case PROP_AXES: + g_value_set_flags (value, device->axis_flags); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1515,7 +1532,10 @@ _gdk_device_reset_axes (GdkDevice *device) for (i = device->axes->len - 1; i >= 0; i--) g_array_remove_index (device->axes, i); + device->axis_flags = 0; + g_object_notify_by_pspec (G_OBJECT (device), device_props[PROP_N_AXES]); + g_object_notify_by_pspec (G_OBJECT (device), device_props[PROP_AXES]); } guint @@ -1556,7 +1576,10 @@ _gdk_device_add_axis (GdkDevice *device, device->axes = g_array_append_val (device->axes, axis_info); pos = device->axes->len - 1; + device->axis_flags |= (1 << use); + g_object_notify_by_pspec (G_OBJECT (device), device_props[PROP_N_AXES]); + g_object_notify_by_pspec (G_OBJECT (device), device_props[PROP_AXES]); return pos; } @@ -1964,3 +1987,19 @@ gdk_device_get_seat (GdkDevice *device) return device->seat; } + +/** + * gdk_device_get_axes: + * @device: a #GdkDevice + * + * Returns the axes currently available on the device. + * + * Since: 3.22 + **/ +GdkAxisFlags +gdk_device_get_axes (GdkDevice *device) +{ + g_return_val_if_fail (GDK_IS_DEVICE (device), 0); + + return device->axis_flags; +} |