fix(wayland): prevent libinput unset axis error on scroll#194
Open
uint82 wants to merge 2 commits into
Open
Conversation
Refactor scroll wheel event handling to check for axis presence.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an issue where scrolling a mouse wheel under Wayland causes
libinputto aggressively spam the console with the following error:libinput error: client bug: value requested for unset axisThe Cause:
Currently, when a
PointerScrollWheelEventis received, the code unconditionally requests bothAxis::HorizontalandAxis::Verticalvalues. If the physical mouse only triggered a vertical scroll, requesting the horizontal axis triggers a safety check insidelibinput, resulting in the "client bug" error.The Fix:
I imported the
PointerScrollEventtrait and wrapped the axis value requests in anif btn.has_axis(...)check. If the axis wasn't triggered by the hardware, it safely defaults to0instead of queryinglibinput.Changes Made
use input::event::pointer::PointerScrollEvent;to imports.PointerEvent::ScrollWheel(btn)match arm to verify axis existence before calculatingdelta_xanddelta_y.Additional Context
I ran into this while building a macro recorder for Wayland. My engine bypasses user-space jitter by using
evdevdirectly for recording, but I am still usingrdevto listen for global hotkeys (like F-keys) to start/stop the macros.Whenever I scrolled my mouse wheel, this Wayland axis bug would trigger and spam my macro engine's terminal output. This fix keeps the console completely clean!