Copy axes when rewriting events

This commit is contained in:
Emmanuele Bassi 2020-04-17 22:23:32 +01:00
parent 3e19b9502d
commit d46e1288a4

View File

@ -1084,6 +1084,8 @@ rewrite_event_for_surface (GdkEvent *event,
GdkEventType type;
double x, y;
double dx, dy;
double *axes = NULL;
guint n_axes = 0;
type = gdk_event_get_event_type (event);
@ -1106,6 +1108,16 @@ rewrite_event_for_surface (GdkEvent *event,
break;
}
if (gdk_event_get_axes (event, &axes, &n_axes))
{
double *axes_copy = g_memdup (axes, n_axes * sizeof (double));
/* The newly created event takes ownership of the axes, so
* we need a copy
*/
axes = axes_copy;
}
switch ((guint) type)
{
case GDK_BUTTON_PRESS:
@ -1119,7 +1131,7 @@ rewrite_event_for_surface (GdkEvent *event,
gdk_event_get_modifier_state (event),
gdk_button_event_get_button (event),
x, y,
NULL); // FIXME copy axes
axes);
case GDK_MOTION_NOTIFY:
return gdk_motion_event_new (new_surface,
gdk_event_get_device (event),
@ -1128,7 +1140,7 @@ rewrite_event_for_surface (GdkEvent *event,
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
x, y,
NULL); // FIXME copy axes
axes);
case GDK_TOUCH_BEGIN:
case GDK_TOUCH_UPDATE:
case GDK_TOUCH_END:
@ -1141,7 +1153,7 @@ rewrite_event_for_surface (GdkEvent *event,
gdk_event_get_time (event),
gdk_event_get_modifier_state (event),
x, y,
NULL, // FIXME copy axes
axes,
gdk_touch_event_get_emulating_pointer (event));
case GDK_TOUCHPAD_SWIPE:
gdk_touchpad_event_get_deltas (event, &dx, &dy);