From e38a8363e4b04bfbc0807c5725d65cfb27f3f9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 16 Jun 2016 19:39:56 -0400 Subject: [PATCH] ClutterVirtualInputDevice: Keep track of the device manager https://bugzilla.gnome.org/show_bug.cgi?id=765009 --- .../clutter/clutter-virtual-input-device.c | 103 ++++++++++++++++-- .../clutter/clutter-virtual-input-device.h | 4 + .../evdev/clutter-device-manager-evdev.c | 4 +- 3 files changed, 101 insertions(+), 10 deletions(-) diff --git a/clutter/clutter/clutter-virtual-input-device.c b/clutter/clutter/clutter-virtual-input-device.c index 7ac35a1c0..f79d7c43b 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 c51152118..d1a27d77d 100644 --- a/clutter/clutter/clutter-virtual-input-device.h +++ b/clutter/clutter/clutter-virtual-input-device.h @@ -27,6 +27,8 @@ #include #include +#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 5be160786..f032083d7 100644 --- a/clutter/clutter/evdev/clutter-device-manager-evdev.c +++ b/clutter/clutter/evdev/clutter-device-manager-evdev.c @@ -2182,7 +2182,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); } /*