[gtk+] device: Add a num-touches property



commit f468f0fbb26a5f6199b30112420b12b9cc90a6db
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Feb 25 08:25:14 2016 -0500

    device: Add a num-touches property
    
    Some backends can provide this information for touch devices,
    and it can be useful to have, so add this property.

 gdk/gdkdevice.c        |   25 +++++++++++++++++++++++++
 gdk/gdkdeviceprivate.h |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index db36ced..3edaa52 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -91,6 +91,7 @@ enum {
   PROP_VENDOR_ID,
   PROP_PRODUCT_ID,
   PROP_SEAT,
+  PROP_NUM_TOUCHES,
   LAST_PROP
 };
 
@@ -287,6 +288,24 @@ gdk_device_class_init (GdkDeviceClass *klass)
                            G_PARAM_READWRITE |
                            G_PARAM_STATIC_STRINGS);
 
+  /**
+   * GdkDevice:num-touches:
+   *
+   * The maximal number of concurrent touches on a touch device.
+   * Will be 0 if the device is not a touch device or if the number
+   * of touches is unknown.
+   *
+   * Since: 3.20
+   */
+  device_props[PROP_NUM_TOUCHES] =
+      g_param_spec_uint ("num-touches",
+                         P_("Number of concurrent touches"),
+                         P_("Number of concurrent touches"),
+                         0, G_MAXUINT,
+                         0,
+                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+                         G_PARAM_STATIC_STRINGS);
+
   g_object_class_install_properties (object_class, LAST_PROP, device_props);
 
   /**
@@ -400,6 +419,9 @@ gdk_device_set_property (GObject      *object,
     case PROP_SEAT:
       device->seat = g_value_get_object (value);
       break;
+    case PROP_NUM_TOUCHES:
+      device->num_touches = g_value_get_uint (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -452,6 +474,9 @@ gdk_device_get_property (GObject    *object,
     case PROP_SEAT:
       g_value_set_object (value, device->seat);
       break;
+    case PROP_NUM_TOUCHES:
+      g_value_set_uint (value, device->num_touches);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 7675895..2350d02 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -57,6 +57,7 @@ struct _GdkDevice
   GList *slaves;
   GdkDeviceType type;
   GArray *axes;
+  guint num_touches;
 
   gchar *vendor_id;
   gchar *product_id;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]