gtkwidget: Emulate motion before button press on fallback touch handler

The code has been shuffled so GDK_TOUCH_BEGIN results in a
GDK_MOTION_NOTIFY to the new position and a GDK_BUTTON_PRESS on that same
place. This makes pointer emulation consistent with what X11 does. Even
though button presses have x/y arguments, there's code out there relying
on getting prior motion events.
This commit is contained in:
Carlos Garnacho 2017-10-19 13:55:34 +02:00
parent 29c4d0a3ee
commit 9b874a40ac

View File

@ -7179,17 +7179,43 @@ gtk_widget_real_touch_event (GtkWidget *widget,
GdkEventTouch *event)
{
GdkEvent *bevent;
gboolean return_val;
gint signum;
gboolean return_val = FALSE;
if (!event->emulating_pointer)
return _gtk_widget_run_controllers (widget, (GdkEvent*) event,
GTK_PHASE_BUBBLE);
if (event->type == GDK_TOUCH_UPDATE ||
event->type == GDK_TOUCH_BEGIN)
{
bevent = gdk_event_new (GDK_MOTION_NOTIFY);
bevent->any.window = g_object_ref (event->window);
bevent->any.send_event = FALSE;
bevent->motion.time = event->time;
bevent->button.state = event->state;
bevent->motion.x_root = event->x_root;
bevent->motion.y_root = event->y_root;
bevent->motion.x = event->x;
bevent->motion.y = event->y;
bevent->motion.device = event->device;
bevent->motion.is_hint = FALSE;
bevent->motion.axes = g_memdup (event->axes,
sizeof (gdouble) * gdk_device_get_n_axes (event->device));
gdk_event_set_source_device (bevent, gdk_event_get_source_device ((GdkEvent*)event));
if (event->type == GDK_TOUCH_UPDATE)
bevent->motion.state |= GDK_BUTTON1_MASK;
g_signal_emit (widget, widget_signals[MOTION_NOTIFY_EVENT], 0, bevent, &return_val);
gdk_event_free (bevent);
}
if (event->type == GDK_TOUCH_BEGIN ||
event->type == GDK_TOUCH_END)
{
GdkEventType type;
gint signum;
if (event->type == GDK_TOUCH_BEGIN)
{
@ -7218,31 +7244,11 @@ gtk_widget_real_touch_event (GtkWidget *widget,
if (event->type == GDK_TOUCH_END)
bevent->button.state |= GDK_BUTTON1_MASK;
}
else if (event->type == GDK_TOUCH_UPDATE)
{
signum = MOTION_NOTIFY_EVENT;
bevent = gdk_event_new (GDK_MOTION_NOTIFY);
bevent->any.window = g_object_ref (event->window);
bevent->any.send_event = FALSE;
bevent->motion.time = event->time;
bevent->motion.state = event->state | GDK_BUTTON1_MASK;
bevent->motion.x_root = event->x_root;
bevent->motion.y_root = event->y_root;
bevent->motion.x = event->x;
bevent->motion.y = event->y;
bevent->motion.device = event->device;
bevent->motion.is_hint = FALSE;
bevent->motion.axes = g_memdup (event->axes,
sizeof (gdouble) * gdk_device_get_n_axes (event->device));
gdk_event_set_source_device (bevent, gdk_event_get_source_device ((GdkEvent*)event));
}
else
return FALSE;
g_signal_emit (widget, widget_signals[signum], 0, bevent, &return_val);
g_signal_emit (widget, widget_signals[signum], 0, bevent, &return_val);
gdk_event_free (bevent);
gdk_event_free (bevent);
}
return return_val;
}