* fix(macos): forward back/forward mouse buttons in capture and emulation
OtherMouseDown/Up events on macOS carry a button number field that
distinguishes middle (2), back (3), and forward (4) buttons. The
capture backend was unconditionally mapping all OtherMouse events to
BTN_MIDDLE, silently dropping back/forward. The emulation backend had
no match arms for BTN_BACK/BTN_FORWARD, causing them to be dropped
with a warning.
Fix capture by reading MOUSE_EVENT_BUTTON_NUMBER and mapping 3->BTN_BACK,
4->BTN_FORWARD. Fix emulation by adding match arms for BTN_BACK/BTN_FORWARD
and setting MOUSE_EVENT_BUTTON_NUMBER on the emitted CGEvent so macOS
apps receive the correct button identity.
* fix(macos): track button state and double-clicks by evdev code instead of CGMouseButton
Back, forward, and middle buttons all map to CGMouseButton::Center on
macOS, which caused them to share a single pressed-state boolean and
alias in double-click detection. Replace the ButtonState struct with a
HashSet<u32> keyed by evdev button code so each button is tracked
independently.
---------
Co-authored-by: Ferdinand Schober <ferdinandschober20@gmail.com>
For a session to actually persist, we need to request a persistence mode
which we already do. The portal then returns a restore-token (in the
form of an uuid) to us as part of the response to Start.
This token must then be passed into the *next* session during
SelectDevices to restore the previous session.
The token is officially a single-use token, so we need to overwrite it
every time. In practise the current XDP implementation may re-use the
token but we cannot rely on that.
Reading and writing the token is not async since we expect them to be
uuid-length.
Closes#74.
Using niri as compositor on both sides resulting in: emulation=wlroots capture=layer-shell
Mouse scrolling works fine in terminals, but only scrolls very small amount in google-chrome (in wayland mode)
Using 'wev' to show events, using the real mouse shows
[ 15: wl_pointer] axis_source: 0 (wheel)
[ 15: wl_pointer] axis_value120: axis: 0 (vertical), value120: 120
[ 15: wl_pointer] axis_relative_direction: axis: 0 (vertical), direction: 0
[ 15: wl_pointer] axis: time: 50410752; axis: 0 (vertical), value: 15.000000
Using the lan-mouse shows:
[ 15: wl_pointer] axis_source: 2 (continuous)
[ 15: wl_pointer] axis_value120: axis: 0 (vertical), value120: 1
[ 15: wl_pointer] axis_relative_direction: axis: 0 (vertical), direction: 0
[ 15: wl_pointer] axis: time: -1913142096; axis: 0 (vertical), value: 20.000000
Without axis_source, scrolling over (pinned) tabs also skips one tab.
* Input capture and emulation can now be disabled and will prompt the user to enable again.
* Improved error handling to deliver more useful error messages