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.
This commit is contained in:
Po Lu 2022-03-11 10:44:33 +00:00
parent 88d474308e
commit fc987de94b
2 changed files with 14 additions and 11 deletions

View file

@ -1578,18 +1578,22 @@ class EmacsScrollBar : public BScrollBar
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);
}
}

View file

@ -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