From b279e1a5ece70c2b1bb1ab32572473d0cb667b52 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 12 Mar 2022 00:46:39 +0000 Subject: [PATCH] Slightly improve scrollbar position accounting on Haiku * src/haiku_support.cc (MessageReceived): Use floats for calculating portion and subtract proportion directly. * src/haikuterm.c (haiku_set_scroll_bar_thumb): Take ceiling of value instead of rounding it. --- src/haiku_support.cc | 6 +++--- src/haikuterm.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index dcea69bb9a7..07e3ee2bb64 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1578,20 +1578,20 @@ public: MessageReceived (BMessage *msg) { int32 portion, range; - double proportion; + float 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; + proportion = (float) portion / range; if (!msg->GetBool ("emacs:dragging", false)) { /* 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->SetRange (0, range - portion); this->SetValue (old_value); this->SetProportion (proportion); } diff --git a/src/haikuterm.c b/src/haikuterm.c index 119c54b17ac..4ecc738898e 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -485,7 +485,7 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, } BView_scroll_bar_update (scroll_bar, lrint (size), - BE_SB_MAX, lrint (value), bar->dragging); + BE_SB_MAX, ceil (value), bar->dragging); } static void -- 2.39.2