diff options
| author | Po Lu | 2022-03-11 10:44:33 +0000 |
|---|---|---|
| committer | Po Lu | 2022-03-11 10:44:33 +0000 |
| commit | fc987de94b1aaaf25391a3cc2b7fffdf5e35dccf (patch) | |
| tree | eea3a7cc57c4fa1d9955ae0476eda118fcb73a47 /src | |
| parent | 88d474308e2a0b4a6cac2714135f6bbcae689ed4 (diff) | |
| download | emacs-fc987de94b1aaaf25391a3cc2b7fffdf5e35dccf.tar.gz emacs-fc987de94b1aaaf25391a3cc2b7fffdf5e35dccf.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/haiku_support.cc | 8 | ||||
| -rw-r--r-- | src/haikuterm.c | 17 |
2 files changed, 14 insertions, 11 deletions
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: | |||
| 1578 | MessageReceived (BMessage *msg) | 1578 | MessageReceived (BMessage *msg) |
| 1579 | { | 1579 | { |
| 1580 | int32 portion, range; | 1580 | int32 portion, range; |
| 1581 | double proportion; | ||
| 1581 | 1582 | ||
| 1582 | if (msg->what == SCROLL_BAR_UPDATE) | 1583 | if (msg->what == SCROLL_BAR_UPDATE) |
| 1583 | { | 1584 | { |
| 1584 | old_value = msg->GetInt32 ("emacs:units", 0); | 1585 | old_value = msg->GetInt32 ("emacs:units", 0); |
| 1585 | portion = msg->GetInt32 ("emacs:portion", 0); | 1586 | portion = msg->GetInt32 ("emacs:portion", 0); |
| 1586 | range = msg->GetInt32 ("emacs:range", 0); | 1587 | range = msg->GetInt32 ("emacs:range", 0); |
| 1588 | proportion = (double) portion / range; | ||
| 1587 | 1589 | ||
| 1588 | if (!msg->GetBool ("emacs:dragging", false)) | 1590 | if (!msg->GetBool ("emacs:dragging", false)) |
| 1589 | { | 1591 | { |
| 1590 | this->SetRange (0, range); | 1592 | /* Unlike on Motif, PORTION isn't included in the total |
| 1593 | range of the scroll bar. */ | ||
| 1594 | this->SetRange (0, std::floor ((double) range - (range * proportion))); | ||
| 1591 | this->SetValue (old_value); | 1595 | this->SetValue (old_value); |
| 1592 | this->SetProportion ((float) portion / range); | 1596 | this->SetProportion (proportion); |
| 1593 | } | 1597 | } |
| 1594 | } | 1598 | } |
| 1595 | 1599 | ||
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 <https://www.gnu.org/licenses/>. */ | |||
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | /* Minimum and maximum values used for Haiku scroll bars. */ | 43 | /* Minimum and maximum values used for Haiku scroll bars. */ |
| 44 | #define BE_SB_MAX 10000000 | 44 | #define BE_SB_MAX 12000000 |
| 45 | 45 | ||
| 46 | struct haiku_display_info *x_display_list = NULL; | 46 | struct haiku_display_info *x_display_list = NULL; |
| 47 | extern frame_parm_handler haiku_frame_parm_handlers[]; | 47 | extern frame_parm_handler haiku_frame_parm_handlers[]; |
| @@ -440,8 +440,7 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, | |||
| 440 | int position, int whole) | 440 | int position, int whole) |
| 441 | { | 441 | { |
| 442 | void *scroll_bar = bar->scroll_bar; | 442 | void *scroll_bar = bar->scroll_bar; |
| 443 | float top, shown; | 443 | double top, shown, size, value; |
| 444 | int size, value; | ||
| 445 | 444 | ||
| 446 | if (scroll_bar_adjust_thumb_portion_p) | 445 | if (scroll_bar_adjust_thumb_portion_p) |
| 447 | { | 446 | { |
| @@ -461,8 +460,8 @@ haiku_set_scroll_bar_thumb (struct scroll_bar *bar, int portion, | |||
| 461 | top = 0, shown = 1; | 460 | top = 0, shown = 1; |
| 462 | else | 461 | else |
| 463 | { | 462 | { |
| 464 | top = (float) position / whole; | 463 | top = (double) position / whole; |
| 465 | shown = (float) portion / whole; | 464 | shown = (double) portion / whole; |
| 466 | } | 465 | } |
| 467 | 466 | ||
| 468 | /* Slider size. Must be in the range [1 .. MAX - MIN] where MAX | 467 | /* 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, | |||
| 481 | { | 480 | { |
| 482 | bar->page_size = 0; | 481 | bar->page_size = 0; |
| 483 | 482 | ||
| 484 | size = (((float) portion / whole) * BE_SB_MAX); | 483 | size = (((double) portion / whole) * BE_SB_MAX); |
| 485 | value = (((float) position / whole) * BE_SB_MAX); | 484 | value = (((double) position / whole) * BE_SB_MAX); |
| 486 | } | 485 | } |
| 487 | 486 | ||
| 488 | BView_scroll_bar_update (scroll_bar, size, BE_SB_MAX, value, | 487 | BView_scroll_bar_update (scroll_bar, lrint (size), |
| 489 | bar->dragging); | 488 | BE_SB_MAX, lrint (value), bar->dragging); |
| 490 | } | 489 | } |
| 491 | 490 | ||
| 492 | static void | 491 | static void |