[gtk/wip/carlosg/scroll-overshoot: 36/36] gtk/scrolledwindow: Check for overshoot setting up kinetic scroll helpers
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/carlosg/scroll-overshoot: 36/36] gtk/scrolledwindow: Check for overshoot setting up kinetic scroll helpers
- Date: Sun, 7 Aug 2022 18:27:17 +0000 (UTC)
commit 0e5a97ae58c26b48a75f3a186dc171a5a6e93d98
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jul 29 20:34:55 2022 +0200
gtk/scrolledwindow: Check for overshoot setting up kinetic scroll helpers
We may have situations where velocity is 0/0, but are overshooting. Places where
this happens are mouse wheels, and continuous scroll that ended up still before
finish. In this situation we also want to run the animation for overshoot, so
check for the corresponding axes to also set up the kinetic scroll helper.
Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/4784
gtk/gtkscrolledwindow.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 518e0a4412..116fc9645a 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -3337,6 +3337,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
GdkFrameClock *frame_clock;
gint64 current_time;
double elapsed;
+ int overshoot_x, overshoot_y;
g_return_if_fail (priv->deceleration_id == 0);
@@ -3346,6 +3347,8 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
elapsed = (current_time - priv->last_deceleration_time) / (double)G_TIME_SPAN_SECOND;
priv->last_deceleration_time = current_time;
+ _gtk_scrolled_window_get_overshoot (scrolled_window, &overshoot_x, &overshoot_y);
+
if (may_hscroll (scrolled_window))
{
double lower,upper;
@@ -3354,7 +3357,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
gtk_scrolled_window_accumulate_velocity (&priv->hscrolling, elapsed, &priv->x_velocity);
g_clear_pointer (&priv->hscrolling, gtk_kinetic_scrolling_free);
- if (priv->x_velocity != 0)
+ if (priv->x_velocity != 0 || overshoot_x != 0)
{
hadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
lower = gtk_adjustment_get_lower (hadjustment);
@@ -3381,7 +3384,7 @@ gtk_scrolled_window_start_deceleration (GtkScrolledWindow *scrolled_window)
gtk_scrolled_window_accumulate_velocity (&priv->vscrolling, elapsed, &priv->y_velocity);
g_clear_pointer (&priv->vscrolling, gtk_kinetic_scrolling_free);
- if (priv->y_velocity != 0)
+ if (priv->y_velocity != 0 || overshoot_y != 0)
{
vadjustment = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
lower = gtk_adjustment_get_lower(vadjustment);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]