[gtk/readonly-events-1: 46/49] Stop using gdk_event_get_target
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/readonly-events-1: 46/49] Stop using gdk_event_get_target
- Date: Sun, 16 Feb 2020 14:33:36 +0000 (UTC)
commit bbc16916dc364137890b1dd20fc346918ab357e9
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 16 02:47:39 2020 -0500
Stop using gdk_event_get_target
We can now get the target widget from the gesture
that we are using to find the event in the first
place.
gtk/gtkscrolledwindow.c | 4 +---
gtk/gtkwidget.c | 33 ++++++++++++++++++---------------
gtk/gtkwindow.c | 3 +--
3 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 47dc168dff..9402eed707 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -850,15 +850,13 @@ scrolled_window_drag_begin_cb (GtkScrolledWindow *scrolled_window,
GtkEventSequenceState state;
GdkEventSequence *sequence;
GtkWidget *event_widget;
- const GdkEvent *event;
priv->in_drag = FALSE;
priv->drag_start_x = priv->unclamped_hadj_value;
priv->drag_start_y = priv->unclamped_vadj_value;
gtk_scrolled_window_cancel_deceleration (scrolled_window);
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
- event = gtk_gesture_get_last_event (gesture, sequence);
- event_widget = GTK_WIDGET (gdk_event_get_target (event));
+ event_widget = gtk_gesture_get_last_target (gesture, sequence);
if (event_widget == priv->vscrollbar || event_widget == priv->hscrollbar ||
(!may_hscroll (scrolled_window) && !may_vscroll (scrolled_window)))
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index aa889265c4..22aa7a9b9b 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2044,15 +2044,14 @@ gtk_widget_get_property (GObject *object,
static void
_gtk_widget_emulate_press (GtkWidget *widget,
- const GdkEvent *event)
+ const GdkEvent *event,
+ GtkWidget *event_widget)
{
- GtkWidget *event_widget, *next_child, *parent;
+ GtkWidget *next_child, *parent;
GdkEvent *press;
gdouble x, y;
graphene_point_t p;
- event_widget = GTK_WIDGET (gdk_event_get_target (event));
-
if (event_widget == widget)
return;
@@ -2136,8 +2135,9 @@ _gtk_widget_emulate_press (GtkWidget *widget,
}
static const GdkEvent *
-_gtk_widget_get_last_event (GtkWidget *widget,
- GdkEventSequence *sequence)
+_gtk_widget_get_last_event (GtkWidget *widget,
+ GdkEventSequence *sequence,
+ GtkWidget **target)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkEventController *controller;
@@ -2151,12 +2151,15 @@ _gtk_widget_get_last_event (GtkWidget *widget,
if (!GTK_IS_GESTURE (controller))
continue;
- event = gtk_gesture_get_last_event (GTK_GESTURE (controller),
- sequence);
+ event = gtk_gesture_get_last_event (GTK_GESTURE (controller), sequence);
if (event)
- return event;
+ {
+ *target = gtk_gesture_get_last_target (GTK_GESTURE (controller), sequence);
+ return event;
+ }
}
+ *target = NULL;
return NULL;
}
@@ -2173,8 +2176,9 @@ _gtk_widget_get_emulating_sequence (GtkWidget *widget,
if (sequence)
{
const GdkEvent *last_event;
+ GtkWidget *target;
- last_event = _gtk_widget_get_last_event (widget, sequence);
+ last_event = _gtk_widget_get_last_event (widget, sequence, &target);
if (last_event &&
(last_event->any.type == GDK_TOUCH_BEGIN ||
@@ -2244,6 +2248,7 @@ _gtk_widget_set_sequence_state_internal (GtkWidget *widget,
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
gboolean emulates_pointer, sequence_handled = FALSE;
const GdkEvent *mimic_event;
+ GtkWidget *target;
GList *group = NULL, *l;
GdkEventSequence *seq;
gint n_handled = 0;
@@ -2255,7 +2260,7 @@ _gtk_widget_set_sequence_state_internal (GtkWidget *widget,
group = gtk_gesture_get_group (emitter);
emulates_pointer = _gtk_widget_get_emulating_sequence (widget, sequence, &seq);
- mimic_event = _gtk_widget_get_last_event (widget, seq);
+ mimic_event = _gtk_widget_get_last_event (widget, seq, &target);
for (l = priv->event_controllers; l; l = l->next)
{
@@ -2318,7 +2323,7 @@ _gtk_widget_set_sequence_state_internal (GtkWidget *widget,
if (n_handled > 0 && sequence_handled &&
state == GTK_EVENT_SEQUENCE_DENIED &&
gtk_widget_needs_press_emulation (widget, sequence))
- _gtk_widget_emulate_press (widget, mimic_event);
+ _gtk_widget_emulate_press (widget, mimic_event, target);
g_list_free (group);
@@ -11899,13 +11904,11 @@ gtk_widget_cancel_event_sequence (GtkWidget *widget,
if (!handled || state != GTK_EVENT_SEQUENCE_CLAIMED)
return;
- event = _gtk_widget_get_last_event (widget, sequence);
+ event = _gtk_widget_get_last_event (widget, sequence, &event_widget);
if (!event)
return;
- event_widget = GTK_WIDGET (gdk_event_get_target (event));
-
while (event_widget)
{
if (event_widget == widget)
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index edc271ebe8..ea8cbaae7f 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1508,8 +1508,7 @@ drag_gesture_update_cb (GtkGestureDrag *gesture,
if (gtk_event_controller_get_propagation_phase (GTK_EVENT_CONTROLLER (gesture)) == GTK_PHASE_CAPTURE)
{
- const GdkEvent *event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
- GtkWidget *event_widget = GTK_WIDGET (gdk_event_get_target (event));
+ GtkWidget *event_widget = gtk_gesture_get_last_target (GTK_GESTURE (gesture), sequence);
/* Check whether the target widget should be left alone at handling
* the sequence, this is better done late to give room for gestures
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]