forked from AuroraMiddleware/gtk
gesturesingle: Implement GtkGesture::cancel better than GtkEventController:reset
The former can be called individually on each sequence, and the latter will always call the former on all currently active sequences, so only implementing resetting on cancel() works for both cases. Also, chain up on subclasses implementing cancel. This fixes clicking on nautilus' file list after popping up a menu, as broken grabs are one of those situations where sequences get cancelled individually, the "current button" wasn't properly reset, and further clicks with button != 3 were ignored.
This commit is contained in:
parent
05810f80a4
commit
6d8842ca96
@ -175,6 +175,14 @@ gtk_gesture_long_press_end (GtkGesture *gesture,
|
||||
priv->cancelled = priv->triggered = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_gesture_long_press_cancel (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence)
|
||||
{
|
||||
gtk_gesture_long_press_end (gesture, sequence);
|
||||
GTK_GESTURE_CLASS (gtk_gesture_long_press_parent_class)->cancel (gesture, sequence);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_gesture_long_press_sequence_state_changed (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence,
|
||||
@ -209,7 +217,7 @@ gtk_gesture_long_press_class_init (GtkGestureLongPressClass *klass)
|
||||
gesture_class->begin = gtk_gesture_long_press_begin;
|
||||
gesture_class->update = gtk_gesture_long_press_update;
|
||||
gesture_class->end = gtk_gesture_long_press_end;
|
||||
gesture_class->cancel = gtk_gesture_long_press_end;
|
||||
gesture_class->cancel = gtk_gesture_long_press_cancel;
|
||||
gesture_class->sequence_state_changed =
|
||||
gtk_gesture_long_press_sequence_state_changed;
|
||||
|
||||
|
@ -279,6 +279,7 @@ gtk_gesture_multi_press_cancel (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence)
|
||||
{
|
||||
_gtk_gesture_multi_press_stop (GTK_GESTURE_MULTI_PRESS (gesture));
|
||||
GTK_GESTURE_CLASS (gtk_gesture_multi_press_parent_class)->cancel (gesture, sequence);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -112,14 +112,15 @@ gtk_gesture_single_set_property (GObject *object,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_gesture_single_reset (GtkEventController *controller)
|
||||
gtk_gesture_single_cancel (GtkGesture *gesture,
|
||||
GdkEventSequence *sequence)
|
||||
{
|
||||
GtkGestureSinglePrivate *priv;
|
||||
|
||||
priv = gtk_gesture_single_get_instance_private (GTK_GESTURE_SINGLE (controller));
|
||||
priv->current_button = 0;
|
||||
priv = gtk_gesture_single_get_instance_private (GTK_GESTURE_SINGLE (gesture));
|
||||
|
||||
GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_single_parent_class)->reset (controller);
|
||||
if (sequence == priv->current_sequence)
|
||||
priv->current_button = 0;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -219,14 +220,16 @@ static void
|
||||
gtk_gesture_single_class_init (GtkGestureSingleClass *klass)
|
||||
{
|
||||
GtkEventControllerClass *controller_class = GTK_EVENT_CONTROLLER_CLASS (klass);
|
||||
GtkGestureClass *gesture_class = GTK_GESTURE_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->get_property = gtk_gesture_single_get_property;
|
||||
object_class->set_property = gtk_gesture_single_set_property;
|
||||
|
||||
controller_class->reset = gtk_gesture_single_reset;
|
||||
controller_class->handle_event = gtk_gesture_single_handle_event;
|
||||
|
||||
gesture_class->cancel = gtk_gesture_single_cancel;
|
||||
|
||||
/**
|
||||
* GtkGestureSingle:touch-only:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user