mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-05-03 08:11:03 +00:00
38f1300717
* fix(linux): enable mouse side buttons in remote sessions Flutter's Linux embedder never delivers X11 button 8/9 (back/forward) events to Dart, so mouse side buttons were silently dropped in remote sessions. Intercept these buttons at the GDK level via button-press/release-event handlers on all windows (main + sub-windows) and forward them through a dedicated platform channel to the active InputModel session. Also add a defensive XSetPointerMapping call during enigo init to extend the X11 core pointer button map to 9 buttons on servers where it is smaller (e.g. minimal X server configurations). * fix: address review feedback for side button support - Use XOpenDisplay/XCloseDisplay instead of reading Display* from xdo_t's private struct layout at offset 0 (fragile ABI assumption) - Track side button down ownership per button via a Map instead of a single slot, preventing cross-button mismatch on overlapping presses * fix: gate side buttons on view-only and fix teardown - Skip side button events in view-only sessions (consistent with other mouse entry points) - Release held side buttons on session close to avoid stuck buttons on the remote - Drop unpaired 'up' events instead of falling back to the active model, which could send to the wrong session * docs: add clarifying comments from review feedback - Note global scope of XSetPointerMapping and that it runs once via lazy_static singleton - Clarify sub-window callback is safe on X11-only builds - Document per-isolate design of initSideButtonChannel * fix: replace broken XSetPointerMapping with diagnostic check XSetPointerMapping requires the length to match XGetPointerMapping's return value - it cannot extend the button count. The previous code would trigger a BadValue X error on servers with fewer than 9 buttons. Replace with a diagnostic-only check that logs whether the core pointer has enough buttons for side button simulation. RustDesk's uinput "Mouse passthrough" device already provides the needed buttons in practice. Also add .catchError to fire-and-forget side button releases during session teardown to prevent unhandled async errors. * fix: ensure side button releases bypass permission checks If permissions change between button down and up (e.g. keyboardPerm revoked, view-only toggled), sendMouse's early return would suppress the release, leaving a stuck button on the remote. Add _sendMouseUnchecked that bypasses permission checks, used for: - Side button 'up' events (matching a recorded 'down') - Forced releases during session teardown Gate all permission checks (isViewOnly, keyboardPerm, isViewCamera) at the 'down' entry point before recording in _sideButtonDownModels. * fix: add NULL guards and avoid blocking platform channel handler - Add NULL checks for FL_VIEW cast and channel creation in on_subwindow_created (review feedback from fufesou) - Use fire-and-forget (unawaited) for _sendMouseUnchecked calls inside the platform channel handler to avoid blocking platform messages when sessionSendMouse is slow (review feedback from Copilot) * fix: remove circular import and skip X11 check on Wayland - Move initSideButtonChannel() call from initEnv() in main.dart to the InputModel constructor, removing the circular import between main.dart and input_model.dart - Skip check_x11_button_map() when DISPLAY is not set to avoid noisy warnings on pure Wayland environments
enigo
Cross platform input simulation in Rust!
- Linux (X11) mouse
- Linux (X11) text
- Linux (Wayland) mouse
- Linux (Wayland) text
- MacOS mouse
- MacOS text
- Win mouse
- Win text
- Custom Parser
let mut enigo = Enigo::new();
enigo.mouse_move_to(500, 200);
enigo.mouse_click(MouseButton::Left);
enigo.key_sequence_parse("{+CTRL}a{-CTRL}{+SHIFT}Hello World{-SHIFT}");
for more look at examples
Runtime dependencies
Linux users may have to install libxdo-dev. For example, on Ubuntu:
apt install libxdo-dev
On Arch:
pacman -S xdotool
