Skip to content

Let the Linux hook leave virtual mice to the compositor - #731

Open
TanjimReza wants to merge 2 commits into
mgth:masterfrom
TanjimReza:fix/linux-skip-virtual-mice
Open

TanjimReza wants to merge 2 commits into
mgth:masterfrom
TanjimReza:fix/linux-skip-virtual-mice

Conversation

@TanjimReza

@TanjimReza TanjimReza commented Sep 26, 2026 •

Copy link
Copy Markdown

Problem: the evdev backend grabs every mouse-like device, including virtual ones created by remote-desktop tools (RustDesk, Input Leap, Barrier…). Their motion is swallowed while their button events still reach the compositor through LBM's virtual pointer, so remote clicks land wherever the local cursor happens to be.

Reproduced with RustDesk 1.4.9 on Ubuntu 26.04 / GNOME 50 Wayland, with two monitors at different scales (2560×1440 @ 133% + 1920×1080 @ 100%): an evdev capture showed zero events on RustDesk's device while LBM's pointer re-emitted its clicks.

Change: new opt-in env var LBM_EVDEV_SKIP_VIRTUAL=1. When set, enumerate_mice (rust/crates/lbm-hook/src/hook/linux/evdev/devices.rs) leaves devices under /sys/devices/virtual to the compositor. Default behavior is unchanged, since remappers like input-remapper re-emit the physical mouse through uinput and still need routing.

Testing:

  • Rebased on current master; cargo test -p lbm-hook passes.
  • Built the full app (UI + lbm-hook + lbm-pattern) following packaging/arch/PKGBUILD and installed it on the machine above.
  • With the flag set, the hook grabs only the physical mouse and leaves RustDesk's device alone; RustDesk remote control works (clicks land where the remote cursor is), and local cross-monitor routing behaves as before.

Follow-up: happy to turn this into a toggle in Options (e.g. "Ignore virtual mice (remote desktop tools)"), passed in the ZonesLayout like LoopX, if you'd like that. Let me know where you'd want it.

The evdev backend grabs every relative pointer with BTN_LEFT, including
uinput devices created by remote-desktop tools (RustDesk, Input Leap...).
Their motion is swallowed while buttons still reach the compositor through
the LBM virtual pointer, so remote clicks land at the local cursor.

LBM_EVDEV_SKIP_VIRTUAL=1 leaves nodes under /sys/devices/virtual to the
compositor. Off by default: remappers such as input-remapper re-emit the
physical mouse through uinput and still need routing.
@TanjimReza
TanjimReza force-pushed the fix/linux-skip-virtual-mice branch from 5c62661 to e8a2540 Compare September 26, 2026 09:34
The hot-plug scanner reopened every /dev/input node twice (mice pass,
keyboards pass) every 2 s. Each evdev close waits in synchronize_rcu(),
10-30 ms on audio jack-detection nodes, and the duplicates of devices
the pump already holds were dropped on the pump thread, so the pointer
stuttered at every rescan.

Watch /dev/input with inotify (IN_CREATE | IN_MOVED_TO, 300 ms settle)
and scan only when a node appears, plus once when the scanner starts to
cover the gap after the arm-time enumeration. Removals still go through
the POLLHUP purge. Classify each node in a single pass. The 2 s poll
stays as the fallback when inotify is unavailable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant