emacs-diffs
[Top][All Lists]
Advanced

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

master fc987de94b: Improve scroll bar treatment on Haiku


From: Po Lu
Subject: master fc987de94b: Improve scroll bar treatment on Haiku
Date: Fri, 11 Mar 2022 05:45:31 -0500 (EST)

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

    Improve scroll bar treatment on Haiku
    
    * src/haiku_support.cc (MessageReceived): Subtract portion from
    range of scroll bar.
    * src/haikuterm.c (BE_SB_MAX): Adjust values for better
    rounding.
    (haiku_set_scroll_bar_thumb): Round values instead of
    truncating them.
---
 src/haiku_support.cc |  8 ++++++--
 src/haikuterm.c      | 17 ++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/haiku_support.cc b/src/haiku_support.cc
index 6f5196dc1c..9b85cd6e0a 100644
--- a/src/haiku_support.cc
+++ b/src/haiku_support.cc
@@ -1578,18 +1578,22 @@ public:
   MessageReceived (BMessage *msg)
   {
     int32 portion, range;
+    double proportion;
 
     if (msg->what == SCROLL_BAR_UPDATE)
       {
        old_value = msg->GetInt32 ("emacs:units", 0);
        portion = msg->GetInt32 ("emacs:portion", 0);
        range = msg->GetInt32 ("emacs:range", 0);
+       proportion = (double) portion / range;
 
        if (!msg->GetBool ("emacs:dragging", false))
          {
-           this->SetRange (0, range);
+           /* Unlike on Motif, PORTION isn't included in the total
+              range of the scroll bar.  */
+           this->SetRange (0, std::floor ((double) range - (range * 
proportion)));
            this->SetValue (old_value);
-           this->SetProportion ((float) portion / range);
+           this->SetProportion (proportion);
          }
       }
 
diff --git a/src/haikuterm.c b/src/haikuterm.c
index a7b971f2c1..119c54b17a 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -41,7 +41,7 @@ along with GNU Emacs.  If not, see 
<https://www.gnu.org/licenses/>.  */
 #endif
 
 /* Minimum and maximum values used for Haiku scroll bars.  */
-#define BE_SB_MAX 10000000
+#define BE_SB_MAX 12000000
 
 struct haiku_display_info *x_display_list = NULL;
 extern frame_parm_handler haiku_frame_parm_handlers[];
@@ -440,8 +440,7 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int 
portion,
                            int position, int whole)
 {
   void *scroll_bar = bar->scroll_bar;
-  float top, shown;
-  int size, value;
+  double top, shown, size, value;
 
   if (scroll_bar_adjust_thumb_portion_p)
     {
@@ -461,8 +460,8 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int 
portion,
        top = 0, shown = 1;
       else
        {
-         top = (float) position / whole;
-         shown = (float) portion / whole;
+         top = (double) position / whole;
+         shown = (double) portion / whole;
        }
 
       /* Slider size.  Must be in the range [1 .. MAX - MIN] where MAX
@@ -481,12 +480,12 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int 
portion,
     {
       bar->page_size = 0;
 
-      size = (((float) portion / whole) * BE_SB_MAX);
-      value = (((float) position / whole) * BE_SB_MAX);
+      size = (((double) portion / whole) * BE_SB_MAX);
+      value = (((double) position / whole) * BE_SB_MAX);
     }
 
-  BView_scroll_bar_update (scroll_bar, size, BE_SB_MAX, value,
-                          bar->dragging);
+  BView_scroll_bar_update (scroll_bar, lrint (size),
+                          BE_SB_MAX, lrint (value), bar->dragging);
 }
 
 static void



reply via email to

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