summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHemidark <support@hemidark.net>2022-04-05 14:56:33 -0700
committerHemidark <support@hemidark.net>2022-04-05 15:35:12 -0700
commit0c44851848d3871e61dd7413260eab81e36cb9c0 (patch)
treed881635d2968fdf493abaeb4fa87b7294c33559c
parent21cba193adf150f522c1bd89faa136ba8d9531cd (diff)
downloadgtk+-0c44851848d3871e61dd7413260eab81e36cb9c0.tar.gz
gdk: always populate GDK_AXIS_{X,Y} in merged event history
Since GdkTimeCoord stores only axis values, prior to this change, if a device didn't report GDK_AXIS_X or GDK_AXIS_Y, the history attached to merged motion events wouldn't contain any positional information. Commit 6012276093ea10dc0913c38d9123c37b08a20264 already addressed this issue for devices without tools by storing the event position in GdkTimeCoord using GDK_AXIS_X and GDK_AXIS_Y and augmenting the GdkTimeCoord's axis bitmask accordingly. This change generalizes that workaround to all devices. Note that if a device DOES report values for GDK_AXIS_X and GDK_AXIS_Y, those values won't be overwritten. Closes #4809
-rw-r--r--gdk/gdkevents.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 2ce9b8b72a..cc06e5e0c0 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -757,15 +757,21 @@ gdk_motion_event_push_history (GdkEvent *event,
memset (&hist, 0, sizeof (GdkTimeCoord));
hist.time = gdk_event_get_time (history_event);
+
if (tool)
{
hist.flags = gdk_device_tool_get_axes (tool);
for (i = GDK_AXIS_X; i < GDK_AXIS_LAST; i++)
gdk_event_get_axis (history_event, i, &hist.axes[i]);
}
- else
+
+ /* GdkTimeCoord has no dedicated fields to record event position. For plain
+ * pointer events, and for tools which don't report GDK_AXIS_X/GDK_AXIS_Y
+ * on their own, we surface the position using the X and Y input axes.
+ */
+ if (!(hist.flags & GDK_AXIS_FLAG_X) || !(hist.flags & GDK_AXIS_FLAG_Y))
{
- hist.flags = GDK_AXIS_FLAG_X | GDK_AXIS_FLAG_Y;
+ hist.flags |= GDK_AXIS_FLAG_X | GDK_AXIS_FLAG_Y;
gdk_event_get_position (history_event, &hist.axes[GDK_AXIS_X], &hist.axes[GDK_AXIS_Y]);
}