[gtk/readonly-events-1: 15/35] Reinstate filtering for crossing events
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/readonly-events-1: 15/35] Reinstate filtering for crossing events
- Date: Tue, 18 Feb 2020 05:23:49 +0000 (UTC)
commit aedf312a6357ac3254efcc08d5c2f35ad5ef1d2b
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 16 01:48:50 2020 -0500
Reinstate filtering for crossing events
The event propagation limit should apply to crossing events
as well.
gtk/gtkeventcontroller.c | 58 ++++++++++++++++++++++++++++-------------
gtk/gtkeventcontrollerprivate.h | 4 +++
2 files changed, 44 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkeventcontroller.c b/gtk/gtkeventcontroller.c
index 609c0bc774..16c5e0fc6c 100644
--- a/gtk/gtkeventcontroller.c
+++ b/gtk/gtkeventcontroller.c
@@ -79,6 +79,22 @@ gtk_event_controller_unset_widget (GtkEventController *self)
priv->widget = NULL;
}
+static gboolean
+same_native (GtkWidget *widget,
+ GtkWidget *target)
+{
+ GtkWidget *native;
+ GtkWidget *native2;
+
+ if (!widget || !target)
+ return TRUE;
+
+ native = GTK_WIDGET (gtk_widget_get_native (widget));
+ native2 = GTK_WIDGET (gtk_widget_get_native (widget));
+
+ return native == native2;
+}
+
static gboolean
gtk_event_controller_filter_event_default (GtkEventController *self,
const GdkEvent *event)
@@ -90,28 +106,30 @@ gtk_event_controller_filter_event_default (GtkEventController *self,
if (priv->limit == GTK_LIMIT_SAME_NATIVE)
{
- GtkWidget *native;
- GtkWidget *native2;
- GtkWidget *target;
+ if (same_native (priv->widget, GTK_WIDGET (gdk_event_get_target (event))) &&
+ same_native (priv->widget, GTK_WIDGET (gdk_event_get_related_target (event))))
+ return FALSE;
+
+ return TRUE;
+ }
- native = GTK_WIDGET (gtk_widget_get_native (priv->widget));
+ return FALSE;
+}
- target = GTK_WIDGET (gdk_event_get_target (event));
- if (target)
- {
- native2 = GTK_WIDGET (gtk_widget_get_native (target));
- if (native == native2)
- return FALSE;
- }
+static gboolean
+gtk_event_controller_filter_crossing_default (GtkEventController *self,
+ const GtkCrossingData *crossing)
+{
+ GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (self);
- target = GTK_WIDGET (gdk_event_get_related_target (event));
+ if (priv->widget && !gtk_widget_is_sensitive (priv->widget))
+ return TRUE;
- if (target)
- {
- native2 = GTK_WIDGET (gtk_widget_get_native (target));
- if (native == native2)
- return FALSE;
- }
+ if (priv->limit == GTK_LIMIT_SAME_NATIVE)
+ {
+ if (same_native (priv->widget, crossing->old_target) &&
+ same_native (priv->widget, crossing->new_target))
+ return FALSE;
return TRUE;
}
@@ -212,6 +230,7 @@ gtk_event_controller_class_init (GtkEventControllerClass *klass)
klass->set_widget = gtk_event_controller_set_widget;
klass->unset_widget = gtk_event_controller_unset_widget;
klass->filter_event = gtk_event_controller_filter_event_default;
+ klass->filter_crossing = gtk_event_controller_filter_crossing_default;
klass->handle_event = gtk_event_controller_handle_event_default;
klass->handle_crossing = gtk_event_controller_handle_crossing_default;
@@ -340,6 +359,9 @@ gtk_event_controller_handle_crossing (GtkEventController *controller,
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
+ if (controller_class->filter_crossing (controller, crossing))
+ return;
+
g_object_ref (controller);
controller_class->handle_crossing (controller, crossing, x, y);
g_object_unref (controller);
diff --git a/gtk/gtkeventcontrollerprivate.h b/gtk/gtkeventcontrollerprivate.h
index aed93f311a..461b25dd75 100644
--- a/gtk/gtkeventcontrollerprivate.h
+++ b/gtk/gtkeventcontrollerprivate.h
@@ -52,6 +52,10 @@ struct _GtkEventControllerClass
*/
gboolean (* filter_event) (GtkEventController *controller,
const GdkEvent *event);
+
+ gboolean (* filter_crossing) (GtkEventController *controller,
+ const GtkCrossingData *crossing);
+
gpointer padding[10];
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]