From 97d77c33d9b72838bbec3b4de502b0dd662baf9f Mon Sep 17 00:00:00 2001 From: "Alejandro G. Castro" Date: Mon, 6 Apr 2009 12:34:51 +0000 Subject: [PATCH] 2009-04-06 Alejandro G. Castro * src/hildon-pannable-area.c, (hildon_pannable_area_class_init): increased the minimum velocity. (hildon_pannable_area_button_release_cb): Updated the CURSOR_STOPPED_TIMEOUT, tuning the widge for the new events setup. Review the code to control that last event. Fixes: NB#109790 (Releasing finger in pannable area easily causes unwanted scrolling) --- ChangeLog | 11 ++++++ src/hildon-pannable-area.c | 80 +++++++++++++++++++++++++++++++++----------- 2 files changed, 72 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27ddb6b..413093d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2009-04-06 Alejandro G. Castro + + * src/hildon-pannable-area.c, + (hildon_pannable_area_class_init): increased the minimum velocity. + (hildon_pannable_area_button_release_cb): Updated the + CURSOR_STOPPED_TIMEOUT, tuning the widge for the new events + setup. Review the code to control that last event. + + Fixes: NB#109790 (Releasing finger in pannable area easily causes + unwanted scrolling) + 2009-04-03 Claudio Saavedra Based on a patch by Mox Soini (ext-mox.soini@nokia.com) diff --git a/src/hildon-pannable-area.c b/src/hildon-pannable-area.c index bd9480c..ee067c0 100644 --- a/src/hildon-pannable-area.c +++ b/src/hildon-pannable-area.c @@ -54,7 +54,7 @@ #define RATIO_TOLERANCE 0.000001 #define SCROLL_FADE_TIMEOUT 100 #define MOTION_EVENTS_PER_SECOND 25 -#define CURSOR_STOPPED_TIMEOUT 125 +#define CURSOR_STOPPED_TIMEOUT 80 G_DEFINE_TYPE (HildonPannableArea, hildon_pannable_area, GTK_TYPE_BIN) @@ -365,7 +365,7 @@ hildon_pannable_area_class_init (HildonPannableAreaClass * klass) "Minimum scroll velocity", "Minimum distance the child widget should scroll " "per 'frame', in pixels per frame.", - 0, G_MAXDOUBLE, 0, + 0, G_MAXDOUBLE, 20, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); @@ -2476,14 +2476,58 @@ hildon_pannable_area_button_release_cb (GtkWidget * widget, priv->scroll_indicator_event_interrupt = 0; priv->scroll_delay_counter = priv->scrollbar_fade_delay; -/* This check does not work properly when the system is overloaded */ -#if 0 - if ((priv->last_type == 2)&& - (event->time - priv->last_time > CURSOR_STOPPED_TIMEOUT)) { - priv->vel_y = 0.0; - priv->vel_x = 0.0; + /* move all the way to the last position */ + if (priv->motion_event_scroll_timeout) { + g_source_remove (priv->motion_event_scroll_timeout); + hildon_pannable_area_motion_event_scroll_timeout (HILDON_PANNABLE_AREA (widget)); + priv->motion_x = 0; + priv->motion_y = 0; + } + + if (priv->last_type == 2) { + gdouble delta = event->time - priv->last_time; + + if (priv->mov_mode&HILDON_MOVEMENT_MODE_VERT) { + gdouble dist = event->y - priv->y; + + if (ABS (dist) >= 1.0) { + hildon_pannable_area_calculate_velocity (&priv->vel_y, + delta, + dist, + priv->vmax, + priv->drag_inertia, + priv->force, + priv->sps); + + priv->motion_y = dist; + hildon_pannable_area_motion_event_scroll_timeout (HILDON_PANNABLE_AREA (widget)); + } else + if (delta >= CURSOR_STOPPED_TIMEOUT) { + y = 0; + priv->vel_y = 0; + } + } + + if (priv->mov_mode&HILDON_MOVEMENT_MODE_HORIZ) { + gdouble dist = event->x - priv->x; + + if (ABS (dist) >= 1.0) { + hildon_pannable_area_calculate_velocity (&priv->vel_x, + delta, + dist, + priv->vmax, + priv->drag_inertia, + priv->force, + priv->sps); + priv->motion_x = dist; + hildon_pannable_area_motion_event_scroll_timeout (HILDON_PANNABLE_AREA (widget)); + } else + if (delta >= CURSOR_STOPPED_TIMEOUT) { + x = 0; + priv->vel_x = 0; + } + } } -#endif if ((ABS (priv->vel_y) > 1.0)|| (ABS (priv->vel_x) > 1.0)) { @@ -2493,12 +2537,6 @@ hildon_pannable_area_button_release_cb (GtkWidget * widget, hildon_pannable_area_launch_fade_timeout (HILDON_PANNABLE_AREA (widget), priv->scroll_indicator_alpha); - /* move all the way to the last position */ - if (priv->motion_event_scroll_timeout) { - g_source_remove (priv->motion_event_scroll_timeout); - hildon_pannable_area_motion_event_scroll_timeout (HILDON_PANNABLE_AREA (widget)); - } - priv->clicked = FALSE; if (priv->mode == HILDON_PANNABLE_AREA_MODE_AUTO || @@ -2515,10 +2553,14 @@ hildon_pannable_area_button_release_cb (GtkWidget * widget, priv->vel_x = priv->vmax_overshooting; } - if (!priv->idle_id) - priv->idle_id = gdk_threads_add_timeout ((gint) (1000.0 / (gdouble) priv->sps), - (GSourceFunc) - hildon_pannable_area_timeout, widget); + if ((ABS (priv->vel_y) >= priv->vmin) || + (ABS (priv->vel_x) >= priv->vmin)) { + + if (!priv->idle_id) + priv->idle_id = gdk_threads_add_timeout ((gint) (1000.0 / (gdouble) priv->sps), + (GSourceFunc) + hildon_pannable_area_timeout, widget); + } } priv->last_time = event->time; -- 1.7.9.5