Skip to content

Commit e953bd8

Browse files
authored
Merge pull request #782 from o-sdn-o/gui-bridge
Fix scrollbar scrolling for mouse reporting with non-float coords
2 parents 73178af + 708d96b commit e953bd8

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/netxs/desktopio/application.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace netxs::app
2222

2323
namespace netxs::app::shared
2424
{
25-
static const auto version = "v2025.08.04";
25+
static const auto version = "v2025.08.04a";
2626
static const auto repository = "https://github.com/directvt/vtm";
2727
static const auto usr_config = "~/.config/vtm/settings.xml"s;
2828
static const auto sys_config = "/etc/vtm/settings.xml"s;

src/netxs/desktopio/controls.hpp

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4649,8 +4649,16 @@ namespace netxs::ui
46494649
static constexpr auto Sixa = !Axis; // Orthogonal axis.
46504650
auto d1 = std::abs(delta[Axis]);
46514651
auto d2 = std::abs(delta[Sixa]);
4652-
if (d1 > d2) scroll_air = grip_origin + delta[Axis];
4653-
else scroll_air = grip_origin + delta[Sixa] * r; // Allows precise (1:1) scrolling using the orthogonal axis.
4652+
if (d1 >= d2) scroll_air = grip_origin + delta[Axis];
4653+
else scroll_air = grip_origin + delta[Sixa] * r; // Allows precise (1:1) scrolling using the orthogonal axis.
4654+
s_to_m();
4655+
}
4656+
void stepbyline(si32 delta)
4657+
{
4658+
auto step = delta * r;
4659+
auto prev_scroll_air = scroll_air;
4660+
scroll_air = std::clamp(scroll_air + step, 0.0, (fp64)s);
4661+
grip_origin += scroll_air - prev_scroll_air;
46544662
s_to_m();
46554663
}
46564664
void commit(rect& handle)
@@ -4694,6 +4702,7 @@ namespace netxs::ui
46944702
math calc; // grip: Scrollbar calculator.
46954703
bool on_pager = faux; // grip: .
46964704
fp2d drag_origin; // grip: Drag origin.
4705+
fp2d gear_coord; // grip: Gear coord tracker.
46974706

46984707
template<auto Event>
46994708
void send()
@@ -4746,7 +4755,19 @@ namespace netxs::ui
47464755
base::on(tier::mouserelease, input::key::MouseWheel, [&](hids& gear)
47474756
{
47484757
if (gear.meta(hids::anyCtrl)) return; // Ctrl+Wheel is reserved for zooming.
4749-
if (gear.whlsi) pager(gear.whlsi > 0 ? 1 : -1);
4758+
if (gear.whlsi)
4759+
{
4760+
auto delta = gear.whlsi > 0 ? 1 : -1;
4761+
if (gear.captured(bell::id)) // Allow precise scrolling of text line by line using the mouse wheel while holding down the mouse button.
4762+
{
4763+
calc.stepbyline(-delta);
4764+
send<e2::form::upon::scroll::bycoor::_<Axis>>();
4765+
}
4766+
else
4767+
{
4768+
pager(delta);
4769+
}
4770+
}
47504771
gear.dismiss();
47514772
});
47524773
base::on(tier::mouserelease, input::key::MouseMove, [&](hids& gear)
@@ -4757,13 +4778,11 @@ namespace netxs::ui
47574778
{
47584779
calc.cursor_pos = twod{ gear.coord }[Axis];
47594780
}
4760-
else
4781+
else if (gear_coord(gear.coord))
47614782
{
4762-
if (auto delta = gear.coord - drag_origin)
4763-
{
4764-
calc.stepby(delta);
4765-
send<e2::form::upon::scroll::bycoor::_<Axis>>();
4766-
}
4783+
auto delta = gear.coord - drag_origin;
4784+
calc.stepby(delta);
4785+
send<e2::form::upon::scroll::bycoor::_<Axis>>();
47674786
}
47684787
gear.dismiss();
47694788
}
@@ -4780,6 +4799,7 @@ namespace netxs::ui
47804799
if (dir == 0) // Inside the grip.
47814800
{
47824801
drag_origin = gear.coord;
4802+
gear_coord = gear.coord;
47834803
calc.m_to_s();
47844804
calc.grip_origin = calc.scroll_air;
47854805
calc.captured = true;

0 commit comments

Comments
 (0)