[gtk+/touch-for-3.4: 21/65] scrolledwindow: Ensure the view snaps back when overshooting
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/touch-for-3.4: 21/65] scrolledwindow: Ensure the view snaps back when overshooting
- Date: Fri, 24 Feb 2012 15:26:36 +0000 (UTC)
commit b4f35b4183dd736d943a687b88712e392707469e
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Jan 4 23:58:13 2012 +0100
scrolledwindow: Ensure the view snaps back when overshooting
Instead of just stopping the acceleration source ID, check whether
it is overshooting, and let it snap back if needed after ::grab-notify
and ::button-release-event.
gtk/gtkscrolledwindow.c | 37 +++++++++++++++----------------------
1 files changed, 15 insertions(+), 22 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index baa652c..99a342d 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -2367,24 +2367,6 @@ gtk_scrolled_window_cancel_deceleration (GtkScrolledWindow *scrolled_window)
g_source_remove (priv->deceleration_id);
priv->deceleration_id = 0;
}
-
- /* Ensure the overshoot window is clamped to the adjustments' limits */
- if (_gtk_scrolled_window_get_overshoot (scrolled_window, NULL, NULL))
- {
- GtkAdjustment *vadjustment, *hadjustment;
-
- vadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->vscrollbar));
- hadjustment = gtk_range_get_adjustment (GTK_RANGE (priv->hscrollbar));
-
- _gtk_scrolled_window_set_adjustment_value (scrolled_window,
- vadjustment,
- gtk_adjustment_get_value (vadjustment),
- FALSE, TRUE);
- _gtk_scrolled_window_set_adjustment_value (scrolled_window,
- hadjustment,
- gtk_adjustment_get_value (hadjustment),
- FALSE, TRUE);
- }
}
static void
@@ -2446,6 +2428,9 @@ gtk_scrolled_window_release_captured_event (GtkScrolledWindow *scrolled_window)
priv->button_press_event = NULL;
}
+ if (_gtk_scrolled_window_get_overshoot (scrolled_window, NULL, NULL))
+ gtk_scrolled_window_start_deceleration (scrolled_window);
+
return FALSE;
}
@@ -2492,6 +2477,7 @@ gtk_scrolled_window_captured_button_release (GtkWidget *widget,
GtkScrolledWindowPrivate *priv = scrolled_window->priv;
GtkWidget *child;
GdkEventButton *event;
+ gboolean overshoot;
event = (GdkEventButton *)_event;
@@ -2511,6 +2497,8 @@ gtk_scrolled_window_captured_button_release (GtkWidget *widget,
priv->release_timeout_id = 0;
}
+ overshoot = _gtk_scrolled_window_get_overshoot (scrolled_window, NULL, NULL);
+
if (priv->in_drag)
gdk_device_ungrab (event->device, event->time);
else
@@ -2520,7 +2508,8 @@ gtk_scrolled_window_captured_button_release (GtkWidget *widget,
*/
gtk_scrolled_window_release_captured_event (scrolled_window);
- return FALSE;
+ if (!overshoot)
+ return FALSE;
}
priv->in_drag = FALSE;
@@ -2538,8 +2527,7 @@ gtk_scrolled_window_captured_button_release (GtkWidget *widget,
if (!priv->vscrollbar_visible)
priv->y_velocity = 0;
- if (priv->x_velocity != 0 || priv->y_velocity != 0 ||
- _gtk_scrolled_window_get_overshoot (scrolled_window, NULL, NULL))
+ if (priv->x_velocity != 0 || priv->y_velocity != 0 || overshoot)
{
gtk_scrolled_window_start_deceleration (scrolled_window);
priv->x_velocity = priv->y_velocity = 0;
@@ -3312,7 +3300,12 @@ gtk_scrolled_window_grab_notify (GtkWidget *widget,
priv->release_timeout_id = 0;
}
- gtk_scrolled_window_cancel_deceleration (scrolled_window);
+ if (_gtk_scrolled_window_get_overshoot (scrolled_window, NULL, NULL))
+ gtk_scrolled_window_start_deceleration (scrolled_window);
+ else
+ gtk_scrolled_window_cancel_deceleration (scrolled_window);
+
+ priv->last_button_event_valid = FALSE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]