ClutterVirtualInputDevice: Keep track of the device manager

https://bugzilla.gnome.org/show_bug.cgi?id=765009
This commit is contained in:
Jonas Ådahl 2016-06-16 19:39:56 -04:00 committed by Carlos Garnacho
parent fb47374629
commit 85e8feca67
5 changed files with 102 additions and 11 deletions

View File

@ -30,7 +30,6 @@
#include <clutter/clutter-input-device.h> #include <clutter/clutter-input-device.h>
#include <clutter/clutter-stage.h> #include <clutter/clutter-stage.h>
#include <clutter/clutter-virtual-input-device.h>
G_BEGIN_DECLS G_BEGIN_DECLS

View File

@ -95,6 +95,7 @@ typedef struct _ClutterState ClutterState;
typedef struct _ClutterInputDeviceTool ClutterInputDeviceTool; typedef struct _ClutterInputDeviceTool ClutterInputDeviceTool;
typedef struct _ClutterInputDevice ClutterInputDevice; typedef struct _ClutterInputDevice ClutterInputDevice;
typedef struct _ClutterVirtualInputDevice ClutterVirtualInputDevice;
typedef CoglMatrix ClutterMatrix; typedef CoglMatrix ClutterMatrix;

View File

@ -29,20 +29,29 @@
#include "clutter-virtual-input-device.h" #include "clutter-virtual-input-device.h"
G_DEFINE_TYPE (ClutterVirtualInputDevice, #include "clutter-device-manager.h"
#include "clutter-private.h"
enum
{
PROP_0,
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, clutter_virtual_input_device,
G_TYPE_OBJECT) G_TYPE_OBJECT)
static void
clutter_virtual_input_device_init (ClutterVirtualInputDevice *virtual_device)
{
}
static void
clutter_virtual_input_device_class_init (ClutterVirtualInputDeviceClass *klass)
{
}
void void
clutter_virtual_input_device_notify_relative_motion (ClutterVirtualInputDevice *virtual_device, clutter_virtual_input_device_notify_relative_motion (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us, uint64_t time_us,
@ -90,3 +99,79 @@ clutter_virtual_input_device_notify_key (ClutterVirtualInputDevice *virtual_devi
klass->notify_key (virtual_device, time_us, key, key_state); 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);
}

View File

@ -27,6 +27,8 @@
#include <glib-object.h> #include <glib-object.h>
#include <stdint.h> #include <stdint.h>
#include "clutter-device-manager.h"
#define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE (clutter_virtual_input_device_get_type ()) #define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE (clutter_virtual_input_device_get_type ())
G_DECLARE_DERIVABLE_TYPE (ClutterVirtualInputDevice, G_DECLARE_DERIVABLE_TYPE (ClutterVirtualInputDevice,
clutter_virtual_input_device, clutter_virtual_input_device,
@ -90,4 +92,6 @@ void clutter_virtual_input_device_notify_key (ClutterVirtualInputDevice *virtual
uint32_t key, uint32_t key,
ClutterKeyState key_state); ClutterKeyState key_state);
ClutterDeviceManager * clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device);
#endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_H__ */ #endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_H__ */

View File

@ -2186,7 +2186,9 @@ static ClutterVirtualInputDevice *
clutter_device_manager_evdev_create_virtual_device (ClutterDeviceManager *manager, clutter_device_manager_evdev_create_virtual_device (ClutterDeviceManager *manager,
ClutterInputDeviceType device_type) 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);
} }
/* /*