summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2014-06-13 01:08:16 +0200
committerCarlos Garnacho <carlosg@gnome.org>2014-06-13 01:27:31 +0200
commit6d8842ca9611862a9730ce3370ccba36946bbe04 (patch)
tree0d93bf0434c2bc77a5afbc755ae52e0b66511294
parent05810f80a4d482ccb3078b5f52eadd0f427fd088 (diff)
downloadgtk+-6d8842ca9611862a9730ce3370ccba36946bbe04.tar.gz
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.
-rw-r--r--gtk/gtkgesturelongpress.c10
-rw-r--r--gtk/gtkgesturemultipress.c1
-rw-r--r--gtk/gtkgesturesingle.c13
3 files changed, 18 insertions, 6 deletions
diff --git a/gtk/gtkgesturelongpress.c b/gtk/gtkgesturelongpress.c
index f2971b3b36..09ac12df4a 100644
--- a/gtk/gtkgesturelongpress.c
+++ b/gtk/gtkgesturelongpress.c
@@ -176,6 +176,14 @@ gtk_gesture_long_press_end (GtkGesture *gesture,
}
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,
GtkEventSequenceState state)
@@ -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;
diff --git a/gtk/gtkgesturemultipress.c b/gtk/gtkgesturemultipress.c
index 1f499768fd..7b0067164c 100644
--- a/gtk/gtkgesturemultipress.c
+++ b/gtk/gtkgesturemultipress.c
@@ -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
diff --git a/gtk/gtkgesturesingle.c b/gtk/gtkgesturesingle.c
index ac91851808..d33f190292 100644
--- a/gtk/gtkgesturesingle.c
+++ b/gtk/gtkgesturesingle.c
@@ -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:
*