From 17fd48efab9c8c42147c1d6319ca653781eac1e6 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 14 Mar 2022 00:54:10 +0000 Subject: [PATCH] Enable overscroll on Haiku horizontal scroll bars * src/haiku_support.cc (MouseMoved): Handle horizontal directions correctly. * src/haikuterm.c (haiku_set_horizontal_scroll_bar_thumb): Enable overscrolling on scroll bar widget. --- src/haiku_support.cc | 17 +++++++++++++---- src/haikuterm.c | 2 +- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/haiku_support.cc b/src/haiku_support.cc index 3941dc0409d..1c1be178d20 100644 --- a/src/haiku_support.cc +++ b/src/haiku_support.cc @@ -1882,7 +1882,10 @@ public: if (in_overscroll) { - diff = point.y - last_overscroll.y; + if (horizontal) + diff = point.x - last_overscroll.x; + else + diff = point.y - last_overscroll.y; if (diff < 0) { @@ -1894,10 +1897,16 @@ public: bounds = Bounds (); bounds.InsetBy (1.0, 1.0); value = overscroll_start_value; - trough_size = BE_RECT_HEIGHT (bounds); - trough_size -= BE_RECT_WIDTH (bounds) / 2; + trough_size = (horizontal + ? BE_RECT_WIDTH (bounds) + : BE_RECT_HEIGHT (bounds)); + trough_size -= (horizontal + ? BE_RECT_HEIGHT (bounds) + : BE_RECT_WIDTH (bounds)) / 2; if (info.double_arrows) - trough_size -= BE_RECT_WIDTH (bounds) / 2; + trough_size -= (horizontal + ? BE_RECT_HEIGHT (bounds) + : BE_RECT_WIDTH (bounds)) / 2; value += ((double) range / trough_size) * diff; diff --git a/src/haikuterm.c b/src/haikuterm.c index 79828695899..52846fc1450 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c @@ -503,7 +503,7 @@ haiku_set_horizontal_scroll_bar_thumb (struct scroll_bar *bar, int portion, bar->page_size = size; BView_scroll_bar_update (scroll_bar, lrint (size), BE_SB_MAX, - ceil (value), bar->dragging, false); + ceil (value), bar->dragging ? -1 : 0, true); } static struct scroll_bar * -- 2.39.5