[gtk/wip/carlosg/for-master: 4/5] gtkbutton: Check release coordinates on all release event types
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/for-master: 4/5] gtkbutton: Check release coordinates on all release event types
- Date: Fri, 25 Sep 2020 17:25:45 +0000 (UTC)
commit ea6e575901118711be5301858de631ad13832d6f
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Sep 25 19:10:46 2020 +0200
gtkbutton: Check release coordinates on all release event types
The priv->in_button state that used to be relied upon for pointer
events has been reduced over time to a broken state, since the button
does not track crossing events anymore.
Make the coordinate-based checks apply for pointer events too, besides
touch events. This fixes GtkButton mistakenly emitting ::clicked with
pointer button releases outside the widget.
Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/3121
gtk/gtkbutton.c | 26 +-------------------------
1 file changed, 1 insertion(+), 25 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 1bacdc797b..f2e6701850 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -336,28 +336,6 @@ click_pressed_cb (GtkGestureClick *gesture,
priv->button_down = TRUE;
}
-static gboolean
-touch_release_in_button (GtkGestureClick *gesture,
- GtkWidget *widget,
- double x,
- double y)
-{
- GdkEvent *event;
-
- event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (gesture));
-
- if (!event)
- return FALSE;
-
- if (gdk_event_get_event_type (event) != GDK_TOUCH_END)
- return FALSE;
-
- if (!gtk_widget_contains (widget, x, y))
- return FALSE;
-
- return TRUE;
-}
-
static void
click_released_cb (GtkGestureClick *gesture,
guint n_press,
@@ -366,14 +344,12 @@ click_released_cb (GtkGestureClick *gesture,
GtkWidget *widget)
{
GtkButton *button = GTK_BUTTON (widget);
- GtkButtonPrivate *priv = gtk_button_get_instance_private (button);
GdkEventSequence *sequence;
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
gtk_button_do_release (button,
gtk_widget_is_sensitive (GTK_WIDGET (button)) &&
- (priv->in_button ||
- touch_release_in_button (gesture, widget, x, y)));
+ gtk_widget_contains (widget, x, y));
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]