[gtk+/wip/garnacho/gdkseat: 51/74] GdkDevice: Add GdkSeat property and getter



commit 0c1e5c00fa08aeddbb64d4f39adb1b43b74fc3d9
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Nov 26 19:50:57 2015 +0100

    GdkDevice: Add GdkSeat property and getter
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759309

 docs/reference/gdk/gdk3-sections.txt |    1 +
 gdk/gdkdevice.c                      |   55 ++++++++++++++++++++++++++++++++++
 gdk/gdkdevice.h                      |    3 ++
 gdk/gdkdeviceprivate.h               |    6 ++++
 4 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index b8b265d..ba66214 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -732,6 +732,7 @@ gdk_device_get_has_cursor
 gdk_device_get_n_axes
 gdk_device_get_n_keys
 gdk_device_warp
+gdk_device_get_seat
 
 <SUBSECTION>
 gdk_device_grab
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 0e325d6..1fd1ea7 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -90,6 +90,7 @@ enum {
   PROP_N_AXES,
   PROP_VENDOR_ID,
   PROP_PRODUCT_ID,
+  PROP_SEAT,
   LAST_PROP
 };
 
@@ -271,6 +272,21 @@ gdk_device_class_init (GdkDeviceClass *klass)
                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
                            G_PARAM_STATIC_STRINGS);
 
+  /**
+   * GdkDevice:seat:
+   *
+   * #GdkSeat of this device.
+   *
+   * Since: 3.20
+   */
+  device_props[PROP_SEAT] =
+      g_param_spec_object ("seat",
+                           P_("Seat"),
+                           P_("Seat"),
+                           GDK_TYPE_SEAT,
+                           G_PARAM_READWRITE |
+                           G_PARAM_STATIC_STRINGS);
+
   g_object_class_install_properties (object_class, LAST_PROP, device_props);
 
   /**
@@ -381,6 +397,9 @@ gdk_device_set_property (GObject      *object,
     case PROP_PRODUCT_ID:
       device->product_id = g_value_dup_string (value);
       break;
+    case PROP_SEAT:
+      device->seat = g_value_get_object (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -430,6 +449,9 @@ gdk_device_get_property (GObject    *object,
     case PROP_PRODUCT_ID:
       g_value_set_string (value, device->product_id);
       break;
+    case PROP_SEAT:
+      g_value_set_object (value, device->seat);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -1880,3 +1902,36 @@ gdk_device_get_product_id (GdkDevice *device)
 
   return device->product_id;
 }
+
+void
+gdk_device_set_seat (GdkDevice *device,
+                     GdkSeat   *seat)
+{
+  g_return_if_fail (GDK_IS_DEVICE (device));
+  g_return_if_fail (!seat || GDK_IS_SEAT (seat));
+
+  if (device->seat == seat)
+    return;
+
+  device->seat = seat;
+  g_object_notify (G_OBJECT (device), "seat");
+}
+
+/**
+ * gdk_device_get_seat:
+ * @device: A #GdkDevice
+ *
+ * Returns the #GdkSeat the device belongs to.
+ *
+ * Returns: (transfer none): A #GdkSeat. This memory is owned by GTK+ and
+ *          must not be freed.
+ *
+ * Since: 3.20
+ **/
+GdkSeat *
+gdk_device_get_seat (GdkDevice *device)
+{
+  g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+
+  return device->seat;
+}
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index 4894772..a1d9cd3 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -279,6 +279,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_20
+GdkSeat     *gdk_device_get_seat            (GdkDevice *device);
+
 G_END_DECLS
 
 #endif /* __GDK_DEVICE_H__ */
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index ea99897..7675895 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -21,6 +21,7 @@
 #include "gdkdevice.h"
 #include "gdkdevicemanager.h"
 #include "gdkevents.h"
+#include "gdkseat.h"
 
 G_BEGIN_DECLS
 
@@ -59,6 +60,8 @@ struct _GdkDevice
 
   gchar *vendor_id;
   gchar *product_id;
+
+  GdkSeat *seat;
 };
 
 struct _GdkDeviceClass
@@ -176,6 +179,9 @@ GdkWindow * _gdk_device_window_at_position    (GdkDevice        *device,
                                                GdkModifierType  *mask,
                                                gboolean          get_toplevel);
 
+void  gdk_device_set_seat  (GdkDevice *device,
+                            GdkSeat   *seat);
+
 G_END_DECLS
 
 #endif /* __GDK_DEVICE_PRIVATE_H__ */


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