[gtk+] Keep track of axis values
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Keep track of axis values
- Date: Wed, 30 Sep 2009 07:23:59 +0000 (UTC)
commit 0178ebf739cb5c69e83664f25343b1bb022e33f8
Author: Thomas Jaeger <ThJaeger gmail com>
Date: Tue Sep 29 11:57:50 2009 -0400
Keep track of axis values
https://bugzilla.gnome.org/show_bug.cgi?id=588649
gdk/x11/gdkinput-x11.c | 25 +++++++++++++++++++++++--
gdk/x11/gdkinput.c | 2 ++
gdk/x11/gdkinputprivate.h | 1 +
3 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c
index 37841b1..d580fdb 100644
--- a/gdk/x11/gdkinput-x11.c
+++ b/gdk/x11/gdkinput-x11.c
@@ -44,6 +44,10 @@ static void gdk_input_translate_coordinates (GdkDevicePrivate *gdkd
gdouble *axis_out,
gdouble *x_out,
gdouble *y_out);
+static void gdk_input_update_axes (GdkDevicePrivate *gdkdev,
+ gint axes_count,
+ gint first_axis,
+ gint *axis_data);
static guint gdk_input_translate_state (guint state,
guint device_state);
@@ -175,6 +179,7 @@ gdk_input_device_new (GdkDisplay *display,
XValuatorInfo *xvi = (XValuatorInfo *)class;
gdkdev->info.num_axes = xvi->num_axes;
gdkdev->axes = g_new (GdkAxisInfo, xvi->num_axes);
+ gdkdev->axis_data = g_new0 (gint, xvi->num_axes);
gdkdev->info.axes = g_new0 (GdkDeviceAxis, xvi->num_axes);
for (j=0;j<xvi->num_axes;j++)
{
@@ -377,6 +382,19 @@ _gdk_input_common_init (GdkDisplay *display,
}
static void
+gdk_input_update_axes (GdkDevicePrivate *gdkdev,
+ gint axes_count,
+ gint first_axis,
+ gint *axis_data)
+{
+ int i;
+ g_return_if_fail (first_axis >= 0 && first_axis + axes_count <= gdkdev->info.num_axes);
+
+ for (i = 0; i < axes_count; i++)
+ gdkdev->axis_data[first_axis + i] = axis_data[i];
+}
+
+static void
gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev,
GdkWindow *window,
gint *axis_data,
@@ -545,7 +563,9 @@ _gdk_input_common_other_event (GdkEvent *event,
event->button.time = xdbe->time;
event->button.axes = g_new (gdouble, gdkdev->info.num_axes);
- gdk_input_translate_coordinates (gdkdev, window, xdbe->axis_data,
+ gdk_input_update_axes (gdkdev, xdbe->axes_count, xdbe->first_axis,
+ xdbe->axis_data);
+ gdk_input_translate_coordinates (gdkdev, window, gdkdev->axis_data,
event->button.axes,
&event->button.x, &event->button.y);
event->button.x_root = event->button.x + priv->abs_x + input_window->root_x;
@@ -647,7 +667,8 @@ _gdk_input_common_other_event (GdkEvent *event,
event->motion.device = &gdkdev->info;
event->motion.axes = g_new (gdouble, gdkdev->info.num_axes);
- gdk_input_translate_coordinates(gdkdev,window,xdme->axis_data,
+ gdk_input_update_axes (gdkdev, xdme->axes_count, xdme->first_axis, xdme->axis_data);
+ gdk_input_translate_coordinates(gdkdev, window, gdkdev->axis_data,
event->motion.axes,
&event->motion.x,&event->motion.y);
event->motion.x_root = event->motion.x + priv->abs_x + input_window->root_x;
diff --git a/gdk/x11/gdkinput.c b/gdk/x11/gdkinput.c
index 6c3cdbb..25f93dc 100644
--- a/gdk/x11/gdkinput.c
+++ b/gdk/x11/gdkinput.c
@@ -120,7 +120,9 @@ gdk_device_dispose (GObject *object)
gdkdev->xdevice = NULL;
}
g_free (gdkdev->axes);
+ g_free (gdkdev->axis_data);
gdkdev->axes = NULL;
+ gdkdev->axis_data = NULL;
#endif /* !XINPUT_NONE */
g_free (gdkdev->info.name);
diff --git a/gdk/x11/gdkinputprivate.h b/gdk/x11/gdkinputprivate.h
index 51233c7..f67c8a7 100644
--- a/gdk/x11/gdkinputprivate.h
+++ b/gdk/x11/gdkinputprivate.h
@@ -73,6 +73,7 @@ struct _GdkDevicePrivate
#ifndef XINPUT_NONE
/* information about the axes */
GdkAxisInfo *axes;
+ gint *axis_data;
/* Information about XInput device */
XDevice *xdevice;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]