[gtk+/multitouch: 125/129] scrolledwindow: store whether the last button press was valid independently



commit c7eba11400dbd747dffa7c010b1eb3a4443bdc00
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Feb 6 20:11:46 2012 +0100

    scrolledwindow: store whether the last button press was valid independently
    
    Use a separate boolean instead of coding it up in the last button press
    coordinates. This incidentally fixes 0-threshold on kinetic scrolling,
    allowing the child widget to get button releases before it prematurely
    gets ::grab-broken.

 gtk/gtkscrolledwindow.c |   27 +++++++++++----------------
 1 files changed, 11 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 2bac4e6..0fc62fa 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -155,6 +155,7 @@ struct _GtkScrolledWindowPrivate
   GdkDevice             *drag_device;
   guint                  kinetic_scrolling_flags   : 2;
   guint                  in_drag                   : 1;
+  guint                  last_button_event_valid   : 1;
   guint                  captured_event_id;
 
   guint                  release_timeout_id;
@@ -594,8 +595,6 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
   gtk_scrolled_window_update_real_placement (scrolled_window);
   priv->min_content_width = -1;
   priv->min_content_height = -1;
-  priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-  priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
 
   gtk_scrolled_window_set_kinetic_scrolling (scrolled_window,
                                              GTK_KINETIC_SCROLLING_ENABLED |
@@ -2508,13 +2507,13 @@ gtk_scrolled_window_captured_button_release (GtkWidget *widget,
     {
       gtk_scrolled_window_start_deceleration (scrolled_window);
       priv->x_velocity = priv->y_velocity = 0;
-      priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-      priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
+      priv->last_button_event_valid = FALSE;
     }
   else
     {
       priv->last_button_event_x_root = event->x_root;
       priv->last_button_event_y_root = event->y_root;
+      priv->last_button_event_valid = TRUE;
     }
 
   if (priv->kinetic_scrolling_flags & GTK_KINETIC_SCROLLING_CAPTURE_BUTTON_PRESS)
@@ -2562,6 +2561,8 @@ gtk_scrolled_window_captured_motion_notify (GtkWidget *widget,
               g_source_remove (priv->release_timeout_id);
               priv->release_timeout_id = 0;
             }
+
+          priv->last_button_event_valid = FALSE;
           priv->in_drag = TRUE;
         }
       else
@@ -2576,9 +2577,6 @@ gtk_scrolled_window_captured_motion_notify (GtkWidget *widget,
                    NULL,
                    event->time);
 
-  priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-  priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-
   gtk_widget_release_captured_events (widget, FALSE);
 
   _gtk_scrolled_window_get_overshoot (scrolled_window,
@@ -2662,17 +2660,18 @@ gtk_scrolled_window_captured_button_press (GtkWidget *widget,
   /* Check whether the button press is close to the previous one,
    * take that as a shortcut to get the child widget handle events
    */
-  if (ABS (event->x_root - priv->last_button_event_x_root) < TOUCH_BYPASS_CAPTURED_THRESHOLD &&
+  if (priv->last_button_event_valid &&
+      ABS (event->x_root - priv->last_button_event_x_root) < TOUCH_BYPASS_CAPTURED_THRESHOLD &&
       ABS (event->y_root - priv->last_button_event_y_root) < TOUCH_BYPASS_CAPTURED_THRESHOLD)
     {
-      priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-      priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
+      priv->last_button_event_valid = FALSE;
       return GTK_CAPTURED_EVENT_NONE;
     }
 
   priv->last_button_event_x_root = priv->last_motion_event_x_root = event->x_root;
   priv->last_button_event_y_root = priv->last_motion_event_y_root = event->y_root;
   priv->last_motion_event_time = event->time;
+  priv->last_button_event_valid = TRUE;
 
   if (event->button != 1)
     return GTK_CAPTURED_EVENT_NONE;
@@ -2730,10 +2729,7 @@ gtk_scrolled_window_captured_event (GtkWidget *widget,
       if (priv->drag_device)
         flags = gtk_scrolled_window_captured_button_release (widget, event);
       else
-        {
-          priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-          priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-        }
+        priv->last_button_event_valid = FALSE;
       break;
     case GDK_MOTION_NOTIFY:
       if (priv->drag_device)
@@ -3285,8 +3281,7 @@ gtk_scrolled_window_grab_notify (GtkWidget *widget,
       else
         gtk_scrolled_window_cancel_deceleration (scrolled_window);
 
-      priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
-      priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
+      priv->last_button_event_valid = FALSE;
     }
 }
 



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