[gtk+/xi2: 447/1239] Translate axis information from XIDeviceEvents.
- From: Carlos Garnacho <carlosg src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/xi2: 447/1239] Translate axis information from XIDeviceEvents.
- Date: Tue, 29 Sep 2009 10:47:34 +0000 (UTC)
commit 3b3f2832fc829fb3406040c233e9828083633ca7
Author: Carlos Garnacho <carlos lanedo com>
Date: Sun Jul 5 12:35:03 2009 +0100
Translate axis information from XIDeviceEvents.
gdk/gdkdevice.c | 2 +-
gdk/x11/gdkdevice-xi2.c | 13 ++++++++++++-
gdk/x11/gdkdevicemanager-xi2.c | 27 +++++++++++++++++++++++++--
3 files changed, 38 insertions(+), 4 deletions(-)
---
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 54debf9..0c10b14 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -48,7 +48,7 @@ enum {
PROP_DISPLAY,
PROP_NAME,
PROP_INPUT_SOURCE,
- PROP_HAS_CURSOR,
+ PROP_HAS_CURSOR
};
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index 957e10b..fb3a65a 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -53,7 +53,8 @@ G_DEFINE_TYPE (GdkDeviceXI2, gdk_device_xi2, GDK_TYPE_DEVICE)
enum {
PROP_0,
- PROP_DEVICE_ID
+ PROP_DEVICE_ID,
+ PROP_N_AXES
};
static void
@@ -75,6 +76,13 @@ gdk_device_xi2_class_init (GdkDeviceXI2Class *klass)
P_("Device identifier"),
0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class,
+ PROP_N_AXES,
+ g_param_spec_uint ("n-axes",
+ P_("Number of axes"),
+ P_("Number of axes"),
+ 0, G_MAXUINT, 0,
+ G_PARAM_READABLE));
g_type_class_add_private (object_class, sizeof (GdkDeviceXI2Private));
}
@@ -103,6 +111,9 @@ gdk_device_xi2_get_property (GObject *object,
case PROP_DEVICE_ID:
g_value_set_int (value, priv->device_id);
break;
+ case PROP_N_AXES:
+ g_value_set_uint (value, priv->axes->len);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index a880928..1e25120 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -674,6 +674,29 @@ handle_focus_change (GdkWindow *window,
generate_focus_event (window, (in) ? TRUE : FALSE);
}
+static gdouble *
+translate_axes (GdkDevice *device,
+ XIValuatorState *valuators)
+{
+ guint n_axes, i, n;
+ gdouble *axes;
+ double *vals;
+
+ g_object_get (device, "n-axes", &n_axes, NULL);
+
+ axes = g_new0 (gdouble, n_axes);
+ vals = valuators->values;
+ n = 0;
+
+ for (i = 0; i <= valuators->mask_len * 8; i++)
+ {
+ if (XIMaskIsSet (valuators->mask, i))
+ axes[n++] = *vals++;
+ }
+
+ return axes;
+}
+
static gboolean
gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
GdkDisplay *display,
@@ -788,6 +811,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
event->button.device = g_hash_table_lookup (device_manager->id_table,
GUINT_TO_POINTER (xev->deviceid));
+ event->button.axes = translate_axes (event->button.device, xev->valuators);
event->button.state = translate_state (xev->mods, xev->buttons);
event->button.button = xev->detail;
}
@@ -829,8 +853,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator,
/* FIXME: There doesn't seem to be motion hints in XI */
event->motion.is_hint = FALSE;
- /* FIXME: missing axes */
- event->motion.axes = NULL;
+ event->motion.axes = translate_axes (event->motion.device, xev->valuators);
}
break;
case XI_Enter:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]