From 1b70a33cc0fe1c4a30d7170e7a6a1d9e723bd548 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sat, 20 Apr 2013 16:56:40 +0200 Subject: [PATCH] Fixed scrolling over the end of the page. If the scrolling reached the end of the page, further scrolling set higher adjustments. If the user scrolled to top, this didn't take effect immediately. --- src/command.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/command.c b/src/command.c index df05a23..8d993bc 100644 --- a/src/command.c +++ b/src/command.c @@ -308,10 +308,11 @@ gboolean command_navigate(const Arg *arg) gboolean command_scroll(const Arg *arg) { - GtkAdjustment *adjust = (arg->i & VB_SCROLL_AXIS_H) ? vb.gui.adjust_h : vb.gui.adjust_v; - + gdouble max, new; int direction = (arg->i & (1 << 2)) ? 1 : -1; + GtkAdjustment *adjust = (arg->i & VB_SCROLL_AXIS_H) ? vb.gui.adjust_h : vb.gui.adjust_v; + max = gtk_adjustment_get_upper(adjust) - gtk_adjustment_get_page_size(adjust); /* type scroll */ if (arg->i & VB_SCROLL_TYPE_SCROLL) { gdouble value; @@ -323,18 +324,18 @@ gboolean command_scroll(const Arg *arg) } else { value = gtk_adjustment_get_page_size(adjust); } - gtk_adjustment_set_value(adjust, gtk_adjustment_get_value(adjust) + direction * value * count); + new = gtk_adjustment_get_value(adjust) + direction * value * count; } else if (vb.state.count) { /* jump - if count is set to count% of page */ - gdouble max = gtk_adjustment_get_upper(adjust) - gtk_adjustment_get_page_size(adjust); - gtk_adjustment_set_value(adjust, max * vb.state.count / 100); + new = max * vb.state.count / 100; } else if (direction == 1) { /* jump to top */ - gtk_adjustment_set_value(adjust, gtk_adjustment_get_upper(adjust)); + new = gtk_adjustment_get_upper(adjust); } else { /* jump to bottom */ - gtk_adjustment_set_value(adjust, gtk_adjustment_get_lower(adjust)); + new = gtk_adjustment_get_lower(adjust); } + gtk_adjustment_set_value(adjust, new > max ? max : new); vb_set_mode(VB_MODE_NORMAL, false); -- 2.20.1