feat(input): wire native mouse-wheel scroll on Wayland + Win32, normalize all backends to ±1/detent (#32)

Window::onMouseScroll now fires on every backend and speaks one unit:
signed whole detents packed in the uint32 payload, +1 = wheel down
(DOM deltaY sign).

- Wayland: implement the previously-stubbed PointerListenerHandleAxis —
  vertical axis only, wl_fixed_to_double / 15 (libinput's units-per-
  detent), sub-detent remainder accumulated and reset on pointer leave.
- Win32: add the missing WM_MOUSEWHEEL case — -GET_WHEEL_DELTA_WPARAM /
  WHEEL_DELTA with a remainder accumulator for free-spinning wheels.
- DOM: dom-env.js normalizes WheelEvent.deltaY per deltaMode (100px /
  3 lines / 1 page per detent) with the same remainder scheme, so wasm
  delivers the identical unit instead of raw browser-specific deltas.
- Document the contract on Window::onMouseScroll.
- tests/MouseScroll: compositor-free regression test driving the
  Wayland axis handler directly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
catbot 2026-06-12 15:02:28 +00:00
commit 419730f46b
8 changed files with 240 additions and 8 deletions

View file

@ -237,6 +237,34 @@ extern "C" Configuration CrafterBuildProject(std::span<const std::string_view> a
tc.GetInterfacesAndImplementations(ifaces, testImpls);
pcTest.requires_ = { "tool:glslang", "tool:spirv-val" };
cfg.tests.push_back(std::move(pcTest));
// Regression test for issue #32: the Wayland scroll-wheel chain
// (wl_pointer.axis → Window::onMouseScroll). Drives the listener
// callback directly, so it needs no compositor — but it does need
// the Wayland backend compiled in, hence Linux-only.
if (!windows) {
Test scrollTest;
Configuration& sc = scrollTest.config;
sc.path = cfg.path;
sc.name = "MouseScroll";
sc.outputName = "MouseScroll";
sc.type = ConfigurationType::Executable;
sc.target = cfg.target;
sc.march = cfg.march;
sc.mtune = cfg.mtune;
sc.debug = cfg.debug;
sc.sysroot = cfg.sysroot;
sc.dependencies = cfg.dependencies;
sc.externalDependencies = cfg.externalDependencies;
sc.compileFlags = cfg.compileFlags;
sc.linkFlags = cfg.linkFlags;
sc.defines = cfg.defines;
sc.cFiles = cfg.cFiles;
std::vector<fs::path> scrollImpls(impls.begin(), impls.end());
scrollImpls.emplace_back("tests/MouseScroll/main");
sc.GetInterfacesAndImplementations(ifaces, scrollImpls);
cfg.tests.push_back(std::move(scrollTest));
}
}
return cfg;