mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
Keep track of axis values
https://bugzilla.gnome.org/show_bug.cgi?id=588649
This commit is contained in:
parent
ee25051f96
commit
0178ebf739
@ -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++)
|
||||
{
|
||||
@ -376,6 +381,19 @@ _gdk_input_common_init (GdkDisplay *display,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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,
|
||||
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -73,6 +73,7 @@ struct _GdkDevicePrivate
|
||||
#ifndef XINPUT_NONE
|
||||
/* information about the axes */
|
||||
GdkAxisInfo *axes;
|
||||
gint *axis_data;
|
||||
|
||||
/* Information about XInput device */
|
||||
XDevice *xdevice;
|
||||
|
Loading…
Reference in New Issue
Block a user