summaryrefslogtreecommitdiff
path: root/gdk/gdkevents.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-07-28 19:38:24 +0200
committerCarlos Garnacho <carlosg@gnome.org>2020-07-29 01:27:51 +0200
commit4a2bbed157c6036bf8d7c644d86df74d54fe2dc6 (patch)
tree16371232553c9315284f81bb014d0fff22c3f082 /gdk/gdkevents.c
parent7629f6d5333d823b51924682c24cef90eb124d91 (diff)
downloadgtk+-4a2bbed157c6036bf8d7c644d86df74d54fe2dc6.tar.gz
gdk: Make events hold an axis array matching GdkAxisUse
Instead of doing device-specific translations of array positions, use GdkAxisUse as an array index right away.
Diffstat (limited to 'gdk/gdkevents.c')
-rw-r--r--gdk/gdkevents.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 8131d54d59..8e308c560c 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -732,25 +732,24 @@ gdk_motion_event_push_history (GdkEvent *event,
GdkEvent *history_event)
{
GdkMotionEvent *self = (GdkMotionEvent *) event;
+ GdkDeviceTool *tool;
GdkTimeCoord hist;
- GdkDevice *device;
- int i, n_axes;
+ int i;
g_assert (GDK_IS_EVENT_TYPE (event, GDK_MOTION_NOTIFY));
g_assert (GDK_IS_EVENT_TYPE (history_event, GDK_MOTION_NOTIFY));
- device = gdk_event_get_device (history_event);
- n_axes = gdk_device_get_n_axes (device);
+ if (!self->tool)
+ return;
+
+ tool = gdk_event_get_device_tool (history_event);
memset (&hist, 0, sizeof (GdkTimeCoord));
hist.time = gdk_event_get_time (history_event);
- hist.flags = gdk_device_get_axes (device);
+ hist.flags = gdk_device_tool_get_axes (tool);
- for (i = 0; i < n_axes; i++)
- {
- GdkAxisUse use = gdk_device_get_axis_use (device, i);
- gdk_event_get_axis (history_event, use, &hist.axes[use]);
- }
+ for (i = GDK_AXIS_X; i < GDK_AXIS_LAST; i++)
+ gdk_event_get_axis (history_event, i, &hist.axes[i]);
if (G_UNLIKELY (!self->history))
self->history = g_array_new (FALSE, TRUE, sizeof (GdkTimeCoord));
@@ -952,10 +951,8 @@ gdk_event_get_axis (GdkEvent *event,
if (!gdk_event_get_axes (event, &axes, &n_axes))
return FALSE;
- if (axis_use >= gdk_device_get_n_axes (event->device))
- return FALSE;
-
- return gdk_device_get_axis (event->device, axes, axis_use, value);
+ *value = axes[axis_use];
+ return TRUE;
}
/**
@@ -1408,7 +1405,7 @@ gdk_button_event_get_axes (GdkEvent *event,
return FALSE;
*axes = self->axes;
- *n_axes = gdk_device_get_n_axes (source_device);
+ *n_axes = GDK_AXIS_LAST;
return TRUE;
}
@@ -1985,7 +1982,7 @@ gdk_touch_event_get_axes (GdkEvent *event,
return FALSE;
*axes = self->axes;
- *n_axes = gdk_device_get_n_axes (source_device);
+ *n_axes = GDK_AXIS_LAST;
return TRUE;
}
@@ -2865,7 +2862,7 @@ gdk_motion_event_get_axes (GdkEvent *event,
return FALSE;
*axes = self->axes;
- *n_axes = gdk_device_get_n_axes (source_device);
+ *n_axes = GDK_AXIS_LAST;
return TRUE;
}