[gtk/readonly-events-1: 107/149] Stop using gtk_get_event_target



commit 1b2289ad9bb779fd3a61dfcd3c6b4bbe80c5df91
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 15 21:04:08 2020 -0500

    Stop using gtk_get_event_target
    
    This is just a thin wrapper around gdk_event_get_target,
    so use that directly.

 gtk/gtkscrolledwindow.c | 13 +++++++------
 gtk/gtkwidget.c         |  6 +++---
 gtk/gtkwindow.c         |  2 +-
 3 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index d26d84b7b4..55f390b07d 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -853,7 +853,7 @@ scrolled_window_drag_begin_cb (GtkScrolledWindow *scrolled_window,
   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_get_event_target ((GdkEvent *) event);
+  event_widget = GTK_WIDGET (gdk_event_get_target (event));
 
   if (event_widget == priv->vscrollbar || event_widget == priv->hscrollbar ||
       (!may_hscroll (scrolled_window) && !may_vscroll (scrolled_window)))
@@ -1183,6 +1183,7 @@ captured_motion (GtkScrolledWindow *sw,
   GdkInputSource input_source;
   GdkModifierType state;
   GdkEvent *event;
+  GtkWidget *target;
 
   if (!priv->use_indicators)
     return;
@@ -1198,7 +1199,11 @@ captured_motion (GtkScrolledWindow *sw,
 
   gdk_event_get_state (event, &state);
 
-  if (!gtk_get_event_target_with_type (event, GTK_TYPE_SCROLLBAR) &&
+  target = GTK_WIDGET (gdk_event_get_target (event));
+  while (target && !GTK_IS_SCROLLBAR (target))
+    target = gtk_widget_get_parent (target);
+
+  if (!target &&
       (state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) != 0)
     {
       indicator_set_over (&priv->hindicator, FALSE);
@@ -1213,10 +1218,6 @@ captured_motion (GtkScrolledWindow *sw,
     }
   else
     {
-      GtkWidget *target;
-
-      target = gtk_get_event_target_with_type (event, GTK_TYPE_SCROLLBAR);
-
       if (!check_update_scrollbar_proximity (sw, &priv->vindicator, target, x, y))
         check_update_scrollbar_proximity (sw, &priv->hindicator, target, x, y);
       else
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index b975d2b1ef..0e937bd10e 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -2069,7 +2069,7 @@ _gtk_widget_emulate_press (GtkWidget      *widget,
   gdouble x, y;
   graphene_point_t p;
 
-  event_widget = gtk_get_event_target ((GdkEvent *) event);
+  event_widget = GTK_WIDGET (gdk_event_get_target (event));
 
   if (event_widget == widget)
     return;
@@ -4966,7 +4966,7 @@ gtk_widget_event_internal (GtkWidget *widget,
   x = y = 0;
   translate_event_coordinates (event, &x, &y, widget);
 
-  if (widget == gtk_get_event_target (event))
+  if (widget == GTK_WIDGET (gdk_event_get_target (event)))
     return_val |= gtk_widget_run_controllers (widget, event, x, y, GTK_PHASE_TARGET);
 
   if (return_val == FALSE)
@@ -11939,7 +11939,7 @@ gtk_widget_cancel_event_sequence (GtkWidget             *widget,
   if (!event)
     return;
 
-  event_widget = gtk_get_event_target ((GdkEvent *) event);
+  event_widget = GTK_WIDGET (gdk_event_get_target (event));
 
   while (event_widget)
     {
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 6d275e82fc..a8de122391 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1509,7 +1509,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_get_event_target (event);
+          GtkWidget *event_widget = GTK_WIDGET (gdk_event_get_target (event));
 
           /* 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]