[gtk+] gtkflowbox: Drop crossing/motion event handlers



commit c4d57f85f40fce7240149c5caf33622100a521aa
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Sep 15 16:16:24 2017 +0200

    gtkflowbox: Drop crossing/motion event handlers
    
    Those basically controlled priv->active_child_active, which would
    1) trigger a redraw when the pointer enters/leaves it, and 2) ensure
    that press/release happen on the same child for it to be activated.
    
    The former is not necessary, and the latter can be simplified by
    just checking again the child on the coordinates given by the
    ::release gesture handler. This makes all enter/leave/motion_notify
    event handlers unneeded.

 gtk/gtkflowbox.c |   88 +----------------------------------------------------
 1 files changed, 2 insertions(+), 86 deletions(-)
---
diff --git a/gtk/gtkflowbox.c b/gtk/gtkflowbox.c
index a83c9bd..9c32be9 100644
--- a/gtk/gtkflowbox.c
+++ b/gtk/gtkflowbox.c
@@ -635,7 +635,6 @@ struct _GtkFlowBoxPrivate {
   GtkFlowBoxChild  *cursor_child;
   GtkFlowBoxChild  *selected_child;
 
-  gboolean          active_child_active;
   GtkFlowBoxChild  *active_child;
 
   GtkSelectionMode  selection_mode;
@@ -726,22 +725,6 @@ get_visible_children (GtkFlowBox *box)
 }
 
 static void
-gtk_flow_box_update_active (GtkFlowBox      *box,
-                            GtkFlowBoxChild *child)
-{
-  GtkFlowBoxPrivate *priv = BOX_PRIV (box);
-  gboolean val;
-
-  val = priv->active_child == child;
-  if (priv->active_child != NULL &&
-      val != priv->active_child_active)
-    {
-      priv->active_child_active = val;
-      gtk_widget_queue_draw (GTK_WIDGET (box));
-    }
-}
-
-static void
 gtk_flow_box_apply_filter (GtkFlowBox      *box,
                            GtkFlowBoxChild *child)
 {
@@ -2524,8 +2507,6 @@ autoscroll_cb (GtkWidget     *widget,
 
       child = gtk_flow_box_get_child_at_pos (box, x, y);
 
-      gtk_flow_box_update_active (box, child);
-
       if (child != NULL)
         priv->rubberband_last = child;
     }
@@ -2611,50 +2592,6 @@ update_autoscroll_mode (GtkFlowBox *box,
 
 /* Event handling {{{3 */
 
-static gboolean
-gtk_flow_box_enter_notify_event (GtkWidget        *widget,
-                                 GdkEventCrossing *event)
-{
-  GtkFlowBox *box = GTK_FLOW_BOX (widget);
-  GtkFlowBoxChild *child;
-  gdouble x, y;
-
-  if ((gdk_event_get_window ((GdkEvent *) event) !=
-       gtk_widget_get_window (GTK_WIDGET (box))) ||
-      gdk_event_get_coords ((GdkEvent *) event, &x, &y))
-    return GDK_EVENT_PROPAGATE;
-
-  child = gtk_flow_box_get_child_at_pos (box, x, y);
-  gtk_flow_box_update_active (box, child);
-
-  return FALSE;
-}
-
-static gboolean
-gtk_flow_box_leave_notify_event (GtkWidget        *widget,
-                                 GdkEventCrossing *event)
-{
-  GtkFlowBox *box = GTK_FLOW_BOX (widget);
-  GtkFlowBoxChild *child = NULL;
-  gdouble x, y;
-  GdkNotifyType detail;
-
-  if (gdk_event_get_window ((GdkEvent *) event) !=
-      gtk_widget_get_window (GTK_WIDGET (box)))
-    return FALSE;
-
-  gdk_event_get_crossing_detail ((GdkEvent *)event, &detail);
-
-  if (detail != GDK_NOTIFY_INFERIOR)
-    child = NULL;
-  else if (gdk_event_get_coords ((GdkEvent *) event, &x, &y))
-    child = gtk_flow_box_get_child_at_pos (box, x, y);
-
-  gtk_flow_box_update_active (box, child);
-
-  return FALSE;
-}
-
 static void
 gtk_flow_box_drag_gesture_update (GtkGestureDrag *gesture,
                                   gdouble         offset_x,
@@ -2706,23 +2643,6 @@ gtk_flow_box_drag_gesture_update (GtkGestureDrag *gesture,
     }
 }
 
-static gboolean
-gtk_flow_box_motion_notify_event (GtkWidget      *widget,
-                                  GdkEventMotion *event)
-{
-  GtkFlowBox *box = GTK_FLOW_BOX (widget);
-  GtkFlowBoxChild *child;
-  gdouble x, y;
-
-  if (!gdk_event_get_coords ((GdkEvent *) event, &x, &y))
-    return GDK_EVENT_PROPAGATE;
-
-  child = gtk_flow_box_get_child_at_pos (box, x, y);
-  gtk_flow_box_update_active (box, child);
-
-  return GTK_WIDGET_CLASS (gtk_flow_box_parent_class)->motion_notify_event (widget, event);
-}
-
 static void
 gtk_flow_box_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
                                          guint                 n_press,
@@ -2744,7 +2664,6 @@ gtk_flow_box_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
 
   gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
   priv->active_child = child;
-  priv->active_child_active = TRUE;
   gtk_widget_queue_draw (GTK_WIDGET (box));
 
   if (n_press == 2 && !priv->activate_on_single_click)
@@ -2760,7 +2679,8 @@ gtk_flow_box_multipress_gesture_released (GtkGestureMultiPress *gesture,
 {
   GtkFlowBoxPrivate *priv = BOX_PRIV (box);
 
-  if (priv->active_child != NULL && priv->active_child_active)
+  if (priv->active_child != NULL &&
+      priv->active_child == gtk_flow_box_get_child_at_pos (box, x, y))
     {
       if (priv->activate_on_single_click)
         gtk_flow_box_select_and_activate (box, priv->active_child);
@@ -2798,7 +2718,6 @@ gtk_flow_box_multipress_gesture_stopped (GtkGestureMultiPress *gesture,
   GtkFlowBoxPrivate *priv = BOX_PRIV (box);
 
   priv->active_child = NULL;
-  priv->active_child_active = FALSE;
   gtk_widget_queue_draw (GTK_WIDGET (box));
 }
 
@@ -3452,9 +3371,6 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
   object_class->get_property = gtk_flow_box_get_property;
   object_class->set_property = gtk_flow_box_set_property;
 
-  widget_class->enter_notify_event = gtk_flow_box_enter_notify_event;
-  widget_class->leave_notify_event = gtk_flow_box_leave_notify_event;
-  widget_class->motion_notify_event = gtk_flow_box_motion_notify_event;
   widget_class->size_allocate = gtk_flow_box_size_allocate;
   widget_class->unmap = gtk_flow_box_unmap;
   widget_class->focus = gtk_flow_box_focus;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]