forked from AuroraMiddleware/gtk
gtkgesture: Do not coalesce hold events with other touchpad gestures
This delaying of the cancel event was made to avoid intermediate cancellation for >=2fg hold gestures followed by pinch/swipe gestures, and it worked as long as everything was considered to have the same sequence. Since each pinch/swipe pointer gesture now gets its own sequence, this no longer applies, nor works. This results in zoom/rotate/swipe gestures being stuck since the sequence for the touchpad events changes mid-gesture. Sticking to this pattern of giving touchpad gestures their own sequence, these hold events cannot be assumed to coalesce with other touchpad gestures, it is better to let it propagate altogether so that both the hold gesture and the incoming gesture trigger coherent begin and end/cancel phases. In the worst case, this results in "::begin, ::cancel, ::begin , ..." before triggering a touchpad gesture, but the extra begin/cancel ought to be a safe no-op in widgets. Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5003
This commit is contained in:
parent
af6432aa67
commit
023924bca9
@ -162,7 +162,6 @@ struct _GtkGesturePrivate
|
||||
GdkDevice *device;
|
||||
GList *group_link;
|
||||
guint n_points;
|
||||
guint hold_timeout_id;
|
||||
guint recognized : 1;
|
||||
guint touchpad : 1;
|
||||
};
|
||||
@ -175,8 +174,6 @@ static guint signals[N_SIGNALS] = { 0 };
|
||||
gdk_event_get_event_type (e) == GDK_TOUCHPAD_PINCH || \
|
||||
gdk_event_get_event_type (e) == GDK_TOUCHPAD_HOLD)
|
||||
|
||||
#define HOLD_TIMEOUT_MS 50
|
||||
|
||||
GList * _gtk_gesture_get_group_link (GtkGesture *gesture);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkGesture, gtk_gesture, GTK_TYPE_EVENT_CONTROLLER)
|
||||
@ -225,7 +222,6 @@ gtk_gesture_finalize (GObject *object)
|
||||
|
||||
gtk_gesture_ungroup (gesture);
|
||||
g_list_free (priv->group_link);
|
||||
g_clear_handle_id (&priv->hold_timeout_id, g_source_remove);
|
||||
|
||||
g_hash_table_destroy (priv->points);
|
||||
|
||||
@ -583,22 +579,6 @@ _gtk_gesture_cancel_all (GtkGesture *gesture)
|
||||
_gtk_gesture_check_empty (gesture);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_gesture_hold_timeout (gpointer user_data)
|
||||
{
|
||||
GtkGesture *gesture;
|
||||
GtkGesturePrivate *priv;
|
||||
|
||||
gesture = user_data;
|
||||
priv = gtk_gesture_get_instance_private (gesture);
|
||||
|
||||
if (priv->touchpad)
|
||||
_gtk_gesture_cancel_sequence (gesture, priv->last_sequence);
|
||||
|
||||
priv->hold_timeout_id = 0;
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gesture_within_surface (GtkGesture *gesture,
|
||||
GdkSurface *surface)
|
||||
@ -664,10 +644,6 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN) ||
|
||||
(event_type == GDK_TOUCHPAD_HOLD && phase == GDK_TOUCHPAD_GESTURE_PHASE_BEGIN))
|
||||
{
|
||||
if ((event_type == GDK_TOUCHPAD_PINCH || event_type == GDK_TOUCHPAD_SWIPE) &&
|
||||
_gtk_gesture_has_matching_touchpoints (gesture))
|
||||
g_clear_handle_id (&priv->hold_timeout_id, g_source_remove);
|
||||
|
||||
if (_gtk_gesture_update_point (gesture, event, target, x, y, TRUE))
|
||||
{
|
||||
gboolean triggered_recognition;
|
||||
@ -738,20 +714,12 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
_gtk_gesture_cancel_sequence (gesture, sequence);
|
||||
}
|
||||
else if ((event_type == GDK_TOUCHPAD_SWIPE && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL) ||
|
||||
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL))
|
||||
(event_type == GDK_TOUCHPAD_PINCH && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL) ||
|
||||
(event_type == GDK_TOUCHPAD_HOLD && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL))
|
||||
{
|
||||
if (priv->touchpad)
|
||||
_gtk_gesture_cancel_sequence (gesture, sequence);
|
||||
}
|
||||
else if (event_type == GDK_TOUCHPAD_HOLD && phase == GDK_TOUCHPAD_GESTURE_PHASE_CANCEL)
|
||||
{
|
||||
if (priv->hold_timeout_id == 0)
|
||||
{
|
||||
priv->hold_timeout_id = g_timeout_add (HOLD_TIMEOUT_MS,
|
||||
gtk_gesture_hold_timeout,
|
||||
gesture);
|
||||
}
|
||||
}
|
||||
else if (event_type == GDK_GRAB_BROKEN)
|
||||
{
|
||||
GdkSurface *surface;
|
||||
@ -777,10 +745,6 @@ gtk_gesture_handle_event (GtkEventController *controller,
|
||||
static void
|
||||
gtk_gesture_reset (GtkEventController *controller)
|
||||
{
|
||||
GtkGesture *gesture = GTK_GESTURE (controller);
|
||||
GtkGesturePrivate *priv = gtk_gesture_get_instance_private (gesture);
|
||||
|
||||
g_clear_handle_id (&priv->hold_timeout_id, g_source_remove);
|
||||
_gtk_gesture_cancel_all (GTK_GESTURE (controller));
|
||||
}
|
||||
|
||||
@ -949,7 +913,6 @@ gtk_gesture_init (GtkGesture *gesture)
|
||||
priv->points = g_hash_table_new_full (NULL, NULL, NULL,
|
||||
(GDestroyNotify) free_point_data);
|
||||
priv->group_link = g_list_prepend (NULL, gesture);
|
||||
priv->hold_timeout_id = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user