[gtk+/wip/baedert/drawing: 276/396] switch: Remove in_switch flag



commit 9aed933d9da92fb229186c0ffdef6a369a6859cc
Author: Timm Bäder <mail baedert org>
Date:   Sat Jun 17 14:18:14 2017 +0200

    switch: Remove in_switch flag
    
    It's pretty simple and less code to just check whether the gesture
    coords are inside the widget at the one place where we actually used the
    flag.

 gtk/gtkswitch.c |   31 ++++---------------------------
 1 files changed, 4 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkswitch.c b/gtk/gtkswitch.c
index de8b4c6..db6fd47 100644
--- a/gtk/gtkswitch.c
+++ b/gtk/gtkswitch.c
@@ -85,7 +85,6 @@ struct _GtkSwitchPrivate
 
   guint state                 : 1;
   guint is_active             : 1;
-  guint in_switch             : 1;
 
   GtkWidget *on_label;
   GtkWidget *off_label;
@@ -209,12 +208,14 @@ gtk_switch_multipress_gesture_released (GtkGestureMultiPress *gesture,
                                         gdouble               y,
                                         GtkSwitch            *sw)
 {
-  GtkSwitchPrivate *priv = sw->priv;
   GdkEventSequence *sequence;
+  GdkRectangle own_alloc;
 
   sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
 
-  if (priv->in_switch &&
+  gtk_widget_get_own_allocation (GTK_WIDGET (sw), &own_alloc);
+
+  if (gdk_rectangle_contains_point (&own_alloc, x, y) &&
       gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
     gtk_switch_begin_toggle_animation (sw);
 }
@@ -277,28 +278,6 @@ gtk_switch_pan_gesture_drag_end (GtkGestureDrag *gesture,
   gtk_widget_queue_allocate (GTK_WIDGET (sw));
 }
 
-static gboolean
-gtk_switch_enter (GtkWidget        *widget,
-                  GdkEventCrossing *event)
-{
-  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
-
-  priv->in_switch = TRUE;
-
-  return FALSE;
-}
-
-static gboolean
-gtk_switch_leave (GtkWidget        *widget,
-                  GdkEventCrossing *event)
-{
-  GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
-
-  priv->in_switch = FALSE;
-
-  return FALSE;
-}
-
 static void
 gtk_switch_activate (GtkSwitch *sw)
 {
@@ -593,8 +572,6 @@ gtk_switch_class_init (GtkSwitchClass *klass)
   widget_class->measure = gtk_switch_measure;
   widget_class->size_allocate = gtk_switch_size_allocate;
   widget_class->snapshot = gtk_switch_snapshot;
-  widget_class->enter_notify_event = gtk_switch_enter;
-  widget_class->leave_notify_event = gtk_switch_leave;
 
   klass->activate = gtk_switch_activate;
   klass->state_set = state_set;


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