[gtk+/wip/wayland-tablet: 2/23] device: Add gdk_device_get_axes(), and ::axes property
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/wayland-tablet: 2/23] device: Add gdk_device_get_axes(), and ::axes property
- Date: Mon, 22 Jun 2015 17:15:03 +0000 (UTC)
commit ec2d3bb78866239eb8596bae9e87bd71ada7161c
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jan 27 21:35:40 2015 +0000
device: Add gdk_device_get_axes(), and ::axes property
This returns a GdkAxisFlags, holding the axes currently available
through this device.
docs/reference/gdk/gdk3-sections.txt | 1 +
gdk/gdkdevice.c | 42 +++++++++++++++++++++++++++++++++-
gdk/gdkdevice.h | 14 +++++++++++
gdk/gdkdeviceprivate.h | 1 +
4 files changed, 57 insertions(+), 1 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index defd136..cf8bb3f 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -730,6 +730,7 @@ gdk_device_get_display
gdk_device_get_has_cursor
gdk_device_get_n_axes
gdk_device_get_n_keys
+gdk_device_get_axes
gdk_device_warp
<SUBSECTION>
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 59631cf..029c2dc 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -88,7 +88,8 @@ enum {
PROP_HAS_CURSOR,
PROP_N_AXES,
PROP_VENDOR_ID,
- PROP_PRODUCT_ID
+ PROP_PRODUCT_ID,
+ PROP_AXES
};
@@ -268,6 +269,20 @@ gdk_device_class_init (GdkDeviceClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+ /**
+ * GdkDevice:axes:
+ *
+ * The axes currently available for this device.
+ *
+ * Since: 3.16
+ */
+ g_object_class_install_property (object_class,
+ PROP_AXES,
+ g_param_spec_flags ("axes",
+ P_("Axes"),
+ P_("Axes"),
+ GDK_TYPE_AXIS_FLAGS, 0,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/**
* GdkDevice::changed:
@@ -419,6 +434,9 @@ gdk_device_get_property (GObject *object,
case PROP_PRODUCT_ID:
g_value_set_string (value, device->product_id);
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;
@@ -1453,7 +1471,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 (G_OBJECT (device), "n-axes");
+ g_object_notify (G_OBJECT (device), "axes");
}
guint
@@ -1494,7 +1515,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 (G_OBJECT (device), "n-axes");
+ g_object_notify (G_OBJECT (device), "axes");
return pos;
}
@@ -1869,3 +1893,19 @@ gdk_device_get_product_id (GdkDevice *device)
return device->product_id;
}
+
+/**
+ * gdk_device_get_axes:
+ * @device: a #GdkDevice
+ *
+ * Returns the axes currently available on the device.
+ *
+ * Since: 3.16
+ **/
+GdkAxisFlags
+gdk_device_get_axes (GdkDevice *device)
+{
+ g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
+
+ return device->axis_flags;
+}
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index e51b15b..45e0f0e 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -109,6 +109,17 @@ typedef enum
GDK_AXIS_LAST
} GdkAxisUse;
+typedef enum
+{
+ GDK_AXIS_FLAG_X = 1 << GDK_AXIS_X,
+ GDK_AXIS_FLAG_Y = 1 << GDK_AXIS_Y,
+ GDK_AXIS_FLAG_PRESSURE = 1 << GDK_AXIS_PRESSURE,
+ GDK_AXIS_FLAG_XTILT = 1 << GDK_AXIS_XTILT,
+ GDK_AXIS_FLAG_YTILT = 1 << GDK_AXIS_YTILT,
+ GDK_AXIS_FLAG_WHEEL = 1 << GDK_AXIS_WHEEL,
+ GDK_AXIS_FLAG_DISTANCE = 1 << GDK_AXIS_DISTANCE
+} GdkAxisFlags;
+
/**
* GdkDeviceType:
* @GDK_DEVICE_TYPE_MASTER: Device is a master (or virtual) device. There will
@@ -281,6 +292,9 @@ const gchar *gdk_device_get_vendor_id (GdkDevice *device);
GDK_AVAILABLE_IN_3_16
const gchar *gdk_device_get_product_id (GdkDevice *device);
+GDK_AVAILABLE_IN_3_18
+GdkAxisFlags gdk_device_get_axes (GdkDevice *device);
+
G_END_DECLS
#endif /* __GDK_DEVICE_H__ */
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index ea99897..123fa2e 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -46,6 +46,7 @@ struct _GdkDevice
GdkInputMode mode;
gboolean has_cursor;
gint num_keys;
+ GdkAxisFlags axis_flags;
GdkDeviceKey *keys;
GdkDeviceManager *manager;
GdkDisplay *display;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]