[gtk+/xi2: 884/1239] GdkDevice: Add API to establish relations between devices.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 884/1239] GdkDevice: Add API to establish relations between devices.
- Date: Tue, 29 Sep 2009 10:52:42 +0000 (UTC)
commit 6a079cbbf2eb4e86d1d03146438f75ac2acd9682
Author: Carlos Garnacho <carlos lanedo com>
Date: Wed Aug 26 01:35:28 2009 +0200
GdkDevice: Add API to establish relations between devices.
This will be used to relate keyboards and pointers.
gdk/gdkdevice.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkdevice.h | 2 +
gdk/gdkdeviceprivate.h | 2 +
3 files changed, 71 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 7eb15ce..a42209b 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -44,9 +44,11 @@ struct _GdkAxisInfo
struct _GdkDevicePrivate
{
GdkDisplay *display;
+ GdkDisplay *relative;
GArray *axes;
};
+static void gdk_device_dispose (GObject *object);
static void gdk_device_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -63,6 +65,7 @@ enum {
PROP_0,
PROP_DISPLAY,
PROP_NAME,
+ PROP_RELATIVE,
PROP_INPUT_SOURCE,
PROP_INPUT_MODE,
PROP_HAS_CURSOR,
@@ -75,6 +78,7 @@ gdk_device_class_init (GdkDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gdk_device_dispose;
object_class->set_property = gdk_device_set_property;
object_class->get_property = gdk_device_get_property;
@@ -93,6 +97,13 @@ gdk_device_class_init (GdkDeviceClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
+ PROP_RELATIVE,
+ g_param_spec_object ("relative",
+ P_("Relative device"),
+ P_("Corresponding pointer or keyboard to this device"),
+ GDK_TYPE_DEVICE,
+ G_PARAM_READABLE));
+ g_object_class_install_property (object_class,
PROP_INPUT_SOURCE,
g_param_spec_enum ("input-source",
P_("Input source"),
@@ -136,6 +147,23 @@ gdk_device_init (GdkDevice *device)
}
static void
+gdk_device_dispose (GObject *object)
+{
+ GdkDevicePrivate *priv;
+
+ priv = GDK_DEVICE_GET_PRIVATE (object);
+
+ if (priv->relative)
+ {
+ _gdk_device_set_relative (priv->relative, NULL);
+ g_object_unref (priv->relative);
+ priv->relative = NULL;
+ }
+
+ G_OBJECT_CLASS (gdk_device_parent_class)->dispose (object);
+}
+
+static void
gdk_device_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -184,6 +212,9 @@ gdk_device_get_property (GObject *object,
case PROP_DISPLAY:
g_value_set_object (value, priv->display);
break;
+ case PROP_RELATIVE:
+ g_value_set_object (value, priv->relative);
+ break;
case PROP_NAME:
g_value_set_string (value,
device->name);
@@ -326,6 +357,42 @@ gdk_device_get_display (GdkDevice *device)
return priv->display;
}
+GdkDevice *
+gdk_device_get_relative (GdkDevice *device)
+{
+ GdkDevicePrivate *priv;
+
+ g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
+
+ priv = GDK_DEVICE_GET_PRIVATE (device);
+
+ return priv->relative;
+}
+
+void
+_gdk_device_set_relative (GdkDevice *device,
+ GdkDevice *relative)
+{
+ GdkDevicePrivate *priv;
+
+ g_return_if_fail (GDK_IS_DEVICE (device));
+ g_return_if_fail (GDK_IS_DEVICE (relative));
+
+ priv = GDK_DEVICE_GET_PRIVATE (device);
+
+ if (priv->relative == relative)
+ return;
+
+ if (priv->relative)
+ {
+ g_object_unref (priv->relative);
+ priv->relative = NULL;
+ }
+
+ if (relative)
+ priv->relative = g_object_ref (relative);
+}
+
GList *
gdk_device_list_axes (GdkDevice *device)
{
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index f95ef3f..354abf3 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -158,6 +158,8 @@ gboolean gdk_device_get_axis (GdkDevice *device,
gdouble *value);
GdkDisplay * gdk_device_get_display (GdkDevice *device);
+GdkDevice * gdk_device_get_relative (GdkDevice *device);
+
G_END_DECLS
#endif /* __GDK_DEVICE_H__ */
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 123dab2..0db7066 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -72,6 +72,8 @@ struct _GdkDeviceClass
gint *win_y);
};
+void _gdk_device_set_relative (GdkDevice *device,
+ GdkDevice *relative);
void _gdk_device_reset_axes (GdkDevice *device);
guint _gdk_device_add_axis (GdkDevice *device,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]