[gtk+/multitouch: 26/121] scrolledwindow: add another shortcut to bypass event capture
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/multitouch: 26/121] scrolledwindow: add another shortcut to bypass event capture
- Date: Thu, 12 Jan 2012 03:07:45 +0000 (UTC)
commit 4a1b1d1a7248417aa83b1bf8fa4cc8c2c6ac882f
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Nov 1 12:55:06 2011 +0100
scrolledwindow: add another shortcut to bypass event capture
When clicked again close to the previous button press location
(assuming it had ~0 movement), the scrolled window wil allow
the child to handle the events immediately.
This is so the user doesn't have to wait to the p-a-h timeout
in order to operate on the scrolledwindow child.
gtk/gtkscrolledwindow.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 3a8de64..6bc2bc2 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -125,6 +125,7 @@
#define DEFAULT_SCROLLBAR_SPACING 3
#define AUTO_HIDE_SCROLLBARS_TIMEOUT 1000
+#define TOUCH_BYPASS_CAPTURED_THRESHOLD 30
/* Kinetic scrolling */
#define FPS 60
@@ -184,6 +185,9 @@ struct _GtkScrolledWindowPrivate
gdouble deceleration_rate;
gdouble overshoot;
guint accumulated_delta;
+
+ gdouble last_button_event_x_root;
+ gdouble last_button_event_y_root;
};
enum {
@@ -607,6 +611,8 @@ gtk_scrolled_window_init (GtkScrolledWindow *scrolled_window)
priv->min_content_width = -1;
priv->min_content_height = -1;
priv->deceleration_rate = 1.1f;
+ priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
+ priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
}
/**
@@ -2957,6 +2963,12 @@ gtk_scrolled_window_button_release_event (GtkWidget *widget,
distance = gtk_scrolled_window_get_deceleration_distance (scrolled_window, event->x_root, event->y_root);
gtk_scrolled_window_start_deceleration (scrolled_window, distance);
+ if (distance == 0)
+ {
+ priv->last_button_event_x_root = event->x_root;
+ priv->last_button_event_y_root = event->y_root;
+ }
+
/* Reset motion event buffer */
motion_event_list_reset (&priv->motion_events);
@@ -2998,6 +3010,9 @@ gtk_scrolled_window_motion_notify_event (GtkWidget *widget,
return FALSE;
}
+ priv->last_button_event_x_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
+ priv->last_button_event_y_root = -TOUCH_BYPASS_CAPTURED_THRESHOLD;
+
if (priv->button_press_event)
{
gdk_event_free (priv->button_press_event);
@@ -3056,6 +3071,20 @@ gtk_scrolled_window_button_press_event (GtkWidget *widget,
event = (GdkEventButton *)_event;
+ /* 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 &&
+ 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;
+ return FALSE;
+ }
+
+ priv->last_button_event_x_root = event->x_root;
+ priv->last_button_event_y_root = event->y_root;
+
if (event->button != 1)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]