[gtk/readonly-events-1: 2/33] Stop using gdk_event_get_target
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/readonly-events-1: 2/33] Stop using gdk_event_get_target
- Date: Fri, 21 Feb 2020 04:39:19 +0000 (UTC)
commit 3a252d4e5f6b1978490a8a5ce6f48e1e008e2e4e
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 c11abc1f0b..195c110bbd 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -851,15 +851,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 6f436a2751..0dd15f9ef7 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2064,15 +2064,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;
@@ -2156,8 +2155,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;
@@ -2171,12 +2171,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;
}
@@ -2193,8 +2196,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 ||
@@ -2264,6 +2268,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;
@@ -2275,7 +2280,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)
{
@@ -2338,7 +2343,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);
@@ -11919,13 +11924,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 deada73892..b48d97b4ee 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]