[mutter/wip/garnacho/virtual-input-device: 95/107] ClutterVirtualInputDevice: Keep track of the device manager



commit 85e8feca679d005596ee698365e38a61882d1c18
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu Jun 16 19:39:56 2016 -0400

    ClutterVirtualInputDevice: Keep track of the device manager
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765009

 clutter/clutter/clutter-device-manager.h           |    1 -
 clutter/clutter/clutter-types.h                    |    1 +
 clutter/clutter/clutter-virtual-input-device.c     |  103 ++++++++++++++++++--
 clutter/clutter/clutter-virtual-input-device.h     |    4 +
 .../clutter/evdev/clutter-device-manager-evdev.c   |    4 +-
 5 files changed, 102 insertions(+), 11 deletions(-)
---
diff --git a/clutter/clutter/clutter-device-manager.h b/clutter/clutter/clutter-device-manager.h
index 6ff52ea..da6bd2c 100644
--- a/clutter/clutter/clutter-device-manager.h
+++ b/clutter/clutter/clutter-device-manager.h
@@ -30,7 +30,6 @@
 
 #include <clutter/clutter-input-device.h>
 #include <clutter/clutter-stage.h>
-#include <clutter/clutter-virtual-input-device.h>
 
 G_BEGIN_DECLS
 
diff --git a/clutter/clutter/clutter-types.h b/clutter/clutter/clutter-types.h
index 1e26105..bc71c7d 100644
--- a/clutter/clutter/clutter-types.h
+++ b/clutter/clutter/clutter-types.h
@@ -95,6 +95,7 @@ typedef struct _ClutterState                  ClutterState;
 
 typedef struct _ClutterInputDeviceTool          ClutterInputDeviceTool;
 typedef struct _ClutterInputDevice              ClutterInputDevice;
+typedef struct _ClutterVirtualInputDevice       ClutterVirtualInputDevice;
 
 typedef CoglMatrix                              ClutterMatrix;
 
diff --git a/clutter/clutter/clutter-virtual-input-device.c b/clutter/clutter/clutter-virtual-input-device.c
index 7ac35a1..f79d7c4 100644
--- a/clutter/clutter/clutter-virtual-input-device.c
+++ b/clutter/clutter/clutter-virtual-input-device.c
@@ -29,19 +29,28 @@
 
 #include "clutter-virtual-input-device.h"
 
-G_DEFINE_TYPE (ClutterVirtualInputDevice,
-               clutter_virtual_input_device,
-               G_TYPE_OBJECT)
+#include "clutter-device-manager.h"
+#include "clutter-private.h"
 
-static void
-clutter_virtual_input_device_init (ClutterVirtualInputDevice *virtual_device)
+enum
 {
-}
+  PROP_0,
 
-static void
-clutter_virtual_input_device_class_init (ClutterVirtualInputDeviceClass *klass)
+  PROP_DEVICE_MANAGER,
+
+  PROP_LAST
+};
+
+static GParamSpec *obj_props[PROP_LAST];
+
+typedef struct _ClutterVirtualInputDevicePrivate
 {
-}
+  ClutterDeviceManager *manager;
+} ClutterVirtualInputDevicePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (ClutterVirtualInputDevice,
+                            clutter_virtual_input_device,
+                            G_TYPE_OBJECT)
 
 void
 clutter_virtual_input_device_notify_relative_motion (ClutterVirtualInputDevice *virtual_device,
@@ -90,3 +99,79 @@ clutter_virtual_input_device_notify_key (ClutterVirtualInputDevice *virtual_devi
 
   klass->notify_key (virtual_device, time_us, key, key_state);
 }
+
+ClutterDeviceManager *
+clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device)
+{
+  ClutterVirtualInputDevicePrivate *priv =
+    clutter_virtual_input_device_get_instance_private (virtual_device);
+
+  return priv->manager;
+}
+
+static void
+clutter_virtual_input_device_get_property (GObject    *object,
+                                           guint       prop_id,
+                                           GValue     *value,
+                                           GParamSpec *pspec)
+{
+  ClutterVirtualInputDevice *virtual_device =
+    CLUTTER_VIRTUAL_INPUT_DEVICE (object);
+  ClutterVirtualInputDevicePrivate *priv =
+    clutter_virtual_input_device_get_instance_private (virtual_device);
+
+  switch (prop_id)
+    {
+    case PROP_DEVICE_MANAGER:
+      g_value_set_object (value, priv->manager);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+clutter_virtual_input_device_set_property (GObject      *object,
+                                           guint         prop_id,
+                                           const GValue *value,
+                                           GParamSpec   *pspec)
+{
+  ClutterVirtualInputDevice *virtual_device =
+    CLUTTER_VIRTUAL_INPUT_DEVICE (object);
+  ClutterVirtualInputDevicePrivate *priv =
+    clutter_virtual_input_device_get_instance_private (virtual_device);
+
+  switch (prop_id)
+    {
+    case PROP_DEVICE_MANAGER:
+      priv->manager = g_value_get_object (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+clutter_virtual_input_device_init (ClutterVirtualInputDevice *virtual_device)
+{
+}
+
+static void
+clutter_virtual_input_device_class_init (ClutterVirtualInputDeviceClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->get_property = clutter_virtual_input_device_get_property;
+  object_class->set_property = clutter_virtual_input_device_set_property;
+
+  obj_props[PROP_DEVICE_MANAGER] =
+    g_param_spec_object ("device-manager",
+                         P_("Device Manager"),
+                         P_("The device manager instance"),
+                         CLUTTER_TYPE_DEVICE_MANAGER,
+                         CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+  g_object_class_install_properties (object_class, PROP_LAST, obj_props);
+}
diff --git a/clutter/clutter/clutter-virtual-input-device.h b/clutter/clutter/clutter-virtual-input-device.h
index c511521..d1a27d7 100644
--- a/clutter/clutter/clutter-virtual-input-device.h
+++ b/clutter/clutter/clutter-virtual-input-device.h
@@ -27,6 +27,8 @@
 #include <glib-object.h>
 #include <stdint.h>
 
+#include "clutter-device-manager.h"
+
 #define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE (clutter_virtual_input_device_get_type ())
 G_DECLARE_DERIVABLE_TYPE (ClutterVirtualInputDevice,
                           clutter_virtual_input_device,
@@ -90,4 +92,6 @@ void clutter_virtual_input_device_notify_key (ClutterVirtualInputDevice *virtual
                                               uint32_t                   key,
                                               ClutterKeyState            key_state);
 
+ClutterDeviceManager * clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device);
+
 #endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_H__ */
diff --git a/clutter/clutter/evdev/clutter-device-manager-evdev.c 
b/clutter/clutter/evdev/clutter-device-manager-evdev.c
index 48270ed..f97ccbb 100644
--- a/clutter/clutter/evdev/clutter-device-manager-evdev.c
+++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c
@@ -2186,7 +2186,9 @@ static ClutterVirtualInputDevice *
 clutter_device_manager_evdev_create_virtual_device (ClutterDeviceManager  *manager,
                                                     ClutterInputDeviceType device_type)
 {
-  return g_object_new (CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE_EVDEV, NULL);
+  return g_object_new (CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE_EVDEV,
+                       "device-manager", manager,
+                       NULL);
 }
 
 /*


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