[gtk/readonly-events-1: 10/18] eventcontroller: Make the target widget available
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/readonly-events-1: 10/18] eventcontroller: Make the target widget available
- Date: Mon, 17 Feb 2020 12:43:02 +0000 (UTC)
commit 2ccda389429060d1d4e997216665ec0b6b8bec22
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 16 02:46:05 2020 -0500
eventcontroller: Make the target widget available
Make it possible for event controllers to obtain
the target widget during handle_event.
gtk/gtkeventcontroller.c | 16 ++++++++++++++++
gtk/gtkeventcontrollerprivate.h | 2 ++
2 files changed, 18 insertions(+)
---
diff --git a/gtk/gtkeventcontroller.c b/gtk/gtkeventcontroller.c
index 34594efa46..c58d986211 100644
--- a/gtk/gtkeventcontroller.c
+++ b/gtk/gtkeventcontroller.c
@@ -58,6 +58,7 @@ struct _GtkEventControllerPrivate
GtkPropagationPhase phase;
GtkPropagationLimit limit;
char *name;
+ GtkWidget *target;
};
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkEventController, gtk_event_controller, G_TYPE_OBJECT)
@@ -323,8 +324,11 @@ gtk_event_controller_handle_event (GtkEventController *controller,
double y)
{
GtkEventControllerClass *controller_class;
+ GtkEventControllerPrivate *priv;
gboolean retval = FALSE;
+ priv = gtk_event_controller_get_instance_private (controller);
+
g_return_val_if_fail (GTK_IS_EVENT_CONTROLLER (controller), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
@@ -333,10 +337,14 @@ gtk_event_controller_handle_event (GtkEventController *controller,
controller_class = GTK_EVENT_CONTROLLER_GET_CLASS (controller);
+ priv->target = target;
+
g_object_ref (controller);
retval = controller_class->handle_event (controller, event, x, y);
g_object_unref (controller);
+ priv->target = NULL;
+
return retval;
}
@@ -516,6 +524,14 @@ gtk_event_controller_set_name (GtkEventController *controller,
priv->name = g_strdup (name);
}
+GtkWidget *
+gtk_event_controller_get_target (GtkEventController *controller)
+{
+ GtkEventControllerPrivate *priv = gtk_event_controller_get_instance_private (controller);
+
+ return priv->target;
+}
+
static GtkCrossingData *
gtk_crossing_data_copy (GtkCrossingData *crossing)
{
diff --git a/gtk/gtkeventcontrollerprivate.h b/gtk/gtkeventcontrollerprivate.h
index 79a61d0314..5c2d341611 100644
--- a/gtk/gtkeventcontrollerprivate.h
+++ b/gtk/gtkeventcontrollerprivate.h
@@ -56,4 +56,6 @@ struct _GtkEventControllerClass
gpointer padding[10];
};
+GtkWidget *gtk_event_controller_get_target (GtkEventController *controller);
+
#endif /* __GTK_EVENT_CONTROLLER_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]