[gtk] widget: Parent widgets may also consume motions
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] widget: Parent widgets may also consume motions
- Date: Tue, 27 Nov 2018 05:18:21 +0000 (UTC)
commit b7963a06ab87a1b1591de3800bda889ba30f05e1
Author: Timm Bäder <mail baedert org>
Date: Wed Nov 21 17:51:10 2018 +0100
widget: Parent widgets may also consume motions
This is important when the target widget of an event is not the one that
would otherwise receive the gesture. For example, the GtkSwitch
implementation currently attaches a pan gesture to the switch itself,
but the target widget below the pointer might be the switch slider or
label.
See #1465
gtk/gtkwidget.c | 31 ++++++++++++++++++-------------
1 file changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 587bf81b0f..eeb5bc6423 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -12925,23 +12925,28 @@ _gtk_widget_consumes_motion (GtkWidget *widget,
GdkEventSequence *sequence)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
- GList *l;
-
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
- for (l = priv->event_controllers; l; l = l->next)
+ while (widget != NULL && !GTK_IS_WINDOW (widget))
{
- GtkEventController *controller = l->data;
+ GList *l;
- if (controller == NULL ||
- !GTK_IS_GESTURE (controller))
- continue;
+ for (l = priv->event_controllers; l; l = l->next)
+ {
+ GtkEventController *controller = l->data;
- if ((!GTK_IS_GESTURE_SINGLE (controller) ||
- GTK_IS_GESTURE_DRAG (controller) ||
- GTK_IS_GESTURE_SWIPE (controller)) &&
- gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence))
- return TRUE;
+ if (controller == NULL ||
+ !GTK_IS_GESTURE (controller))
+ continue;
+
+ if ((!GTK_IS_GESTURE_SINGLE (controller) ||
+ GTK_IS_GESTURE_DRAG (controller) ||
+ GTK_IS_GESTURE_SWIPE (controller)) &&
+ gtk_gesture_handles_sequence (GTK_GESTURE (controller), sequence))
+ return TRUE;
+ }
+
+ widget = priv->parent;
+ priv = gtk_widget_get_instance_private (widget);
}
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]