emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 57172d0a35 1/2: Fix scroll bar movement right before overscroll b


From: Po Lu
Subject: master 57172d0a35 1/2: Fix scroll bar movement right before overscroll begins on Haiku
Date: Sun, 13 Mar 2022 20:55:12 -0400 (EDT)

branch: master
commit 57172d0a35d999c7f7bab6615cb42fe92b172bba
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Fix scroll bar movement right before overscroll begins on Haiku
    
    * src/haikuterm.c (haiku_set_scroll_bar_thumb): Make sure value
    and size are within bounds even if portion adjustment is off.
---
 src/haikuterm.c | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/src/haikuterm.c b/src/haikuterm.c
index 6f8d2eaac5..7982869589 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -455,35 +455,30 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int 
portion,
       /* When the thumb is at the bottom, position == whole.  So we
          need to increase `whole' to make space for the thumb.  */
       whole += portion;
-
-      if (whole <= 0)
-       top = 0, shown = 1;
-      else
-       {
-         top = (double) position / whole;
-         shown = (double) portion / whole;
-       }
-
-      /* Slider size.  Must be in the range [1 .. MAX - MIN] where MAX
-        is the scroll bar's maximum and MIN is the scroll bar's minimum
-        value.  */
-      size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX);
-
-      /* Position.  Must be in the range [MIN .. MAX - SLIDER_SIZE].  */
-      value = top * BE_SB_MAX;
-      value = min (value, BE_SB_MAX - size);
-
-      if (!bar->dragging)
-       bar->page_size = size;
     }
   else
-    {
-      bar->page_size = 0;
+    bar->page_size = 0;
 
-      size = (((double) portion / whole) * BE_SB_MAX);
-      value = (((double) position / whole) * BE_SB_MAX);
+  if (whole <= 0)
+    top = 0, shown = 1;
+  else
+    {
+      top = (double) position / whole;
+      shown = (double) portion / whole;
     }
 
+  /* Slider size.  Must be in the range [1 .. MAX - MIN] where MAX
+     is the scroll bar's maximum and MIN is the scroll bar's minimum
+     value.  */
+  size = clip_to_bounds (1, shown * BE_SB_MAX, BE_SB_MAX);
+
+  /* Position.  Must be in the range [MIN .. MAX - SLIDER_SIZE].  */
+  value = top * BE_SB_MAX;
+  value = min (value, BE_SB_MAX - size);
+
+  if (!bar->dragging && scroll_bar_adjust_thumb_portion_p)
+    bar->page_size = size;
+
   BView_scroll_bar_update (scroll_bar, lrint (size),
                           BE_SB_MAX, ceil (value),
                           (scroll_bar_adjust_thumb_portion_p



reply via email to

[Prev in Thread] Current Thread [Next in Thread]