From: Po Lu Date: Fri, 11 Mar 2022 10:44:33 +0000 (+0000) Subject: Improve scroll bar treatment on Haiku X-Git-Tag: emacs-29.0.90~1931^2~1199 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=fc987de94b1aaaf25391a3cc2b7fffdf5e35dccf;p=emacs.git 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. --- diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 6f5196dc1ce..9b85cd6e0ac 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 a7b971f2c1b..119c54b17ac 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -41,7 +41,7 @@ along with GNU Emacs. If not, see . */ #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