94 Commits

Author SHA1 Message Date
Sergiusz Michalik 38f1300717 fix(linux): enable mouse side buttons in remote sessions (#14848)
* 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
2026-04-25 12:46:05 +08:00
fufesou 732b250815 fix(keyboard): legacy mode (#14435)
* fix(keyboard): legacy mode

Signed-off-by: fufesou <linlong1266@gmail.com>

* Simple refactor

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(keyboard): legacy mode, chr to seq

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(keyboard): legacy mode, early return if (!hotkey)&down

Signed-off-by: fufesou <linlong1266@gmail.com>

* fix(keyboard): legacy mode, pair down/up

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-03-02 19:07:09 +08:00
fufesou 779b7aaf02 feat(wayland): keyboard mode, legacy translate (#14317)
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-02-15 16:43:21 +08:00
fufesou be4bbd018d fix(install): linux xdo (#14096)
Signed-off-by: fufesou <linlong1266@gmail.com>
2026-01-21 20:43:15 +08:00
fufesou 998b75856d feat: Add relative mouse mode (#13928)
* feat: Add relative mouse mode

- Add "Relative Mouse Mode" toggle in desktop toolbar and bind to InputModel
- Implement relative mouse movement path: Flutter pointer deltas -> `type: move_relative` -> new `MOUSE_TYPE_MOVE_RELATIVE` in Rust
- In server input service, simulate relative movement via Enigo and keep latest cursor position in sync
- Track pointer-lock center in Flutter (local widget + screen coordinates) and re-center OS cursor after each relative move
- Update pointer-lock center on window move/resize/restore/maximize and when remote display geometry changes
- Hide local cursor when relative mouse mode is active (both Flutter cursor and OS cursor), restore on leave/disable
- On Windows, clip OS cursor to the window rect while in relative mode and release clip when leaving/turning off
- Implement platform helpers: `get_cursor_pos`, `set_cursor_pos`, `show_cursor`, `clip_cursor` (no-op clip/hide on Linux for now)
- Add keyboard shortcut Ctrl+Alt+Shift+M to toggle relative mode (enabled by default, works on all platforms)
- Remove `enable-relative-mouse-shortcut` config option - shortcut is now always available when keyboard permission is granted
- Handle window blur/focus/minimize events to properly release/restore cursor constraints
- Add MOUSE_TYPE_MASK constant and unit tests for mouse event constants

Note: Relative mouse mode state is NOT persisted to config (session-only).
Note: On Linux, show_cursor and clip_cursor are no-ops; cursor hiding is handled by Flutter side.

Signed-off-by: fufesou <linlong1266@gmail.com>

* feat(mouse): relative mouse mode, exit hint

Signed-off-by: fufesou <linlong1266@gmail.com>

* refact(relative mouse): shortcut

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
2026-01-09 10:03:14 +08:00
fufesou 6144a1c97e fix: osx, reset modifiers' state after locking screen (#11806)
https://github.com/rustdesk/rustdesk/issues/11802

Signed-off-by: fufesou <linlong1266@gmail.com>
2025-05-19 21:02:07 +08:00
fufesou 2d403913b5 fix: enigo, macos, F11 (#11371)
Signed-off-by: fufesou <linlong1266@gmail.com>
2025-04-06 10:42:15 +08:00
fufesou afc8bb71dc feat: mobile, key help tool, more keys (#10068)
* feat: mobile, key help tool, vk_enter

Signed-off-by: fufesou <linlong1266@gmail.com>

* Mobile, add more function keys

Signed-off-by: fufesou <linlong1266@gmail.com>

* Mobile, more virtual function keys

Signed-off-by: fufesou <linlong1266@gmail.com>

* uinput, menu maps key_compose

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
2024-11-29 00:56:38 +08:00
fufesou 7a3e1fe648 fix: ->macos, mouse events, key flags (#9733)
* fix: win->macos, mouse events,  key flags

Signed-off-by: fufesou <linlong1266@gmail.com>

* comments

Signed-off-by: fufesou <linlong1266@gmail.com>

---------

Signed-off-by: fufesou <linlong1266@gmail.com>
2024-10-24 14:33:37 +08:00
fufesou 40239a1c41 feat: macos, mouse button, back&forward (#9185)
Signed-off-by: fufesou <linlong1266@gmail.com>
2024-08-27 15:20:29 +08:00
fufesou d18e95703e fix: mouse forward back (#8705)
Signed-off-by: fufesou <linlong1266@gmail.com>
2024-07-14 03:49:16 +08:00
fufesou 7b37e5183c update rdev, fix grab system utf8, fallback on linux
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-09-15 15:35:44 +08:00
fufesou 6e21f8410a debug, macos trackpad, flutter
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-06-11 15:56:09 +08:00
fufesou c4f9650d7f fix, win mouse, touchpad scroll
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-06-07 20:01:01 +08:00
fufesou f72593c281 tmp commit
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-04-08 19:49:11 +08:00
fufesou 4a8d61ac09 Do not sync led, when Control, Shift, Alt, Tab, Enter are pressed
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-04-08 15:35:10 +08:00
fufesou 850f48abb8 remove unused code from https://github.com/fufesou/ustdsk/comit/b526bf4a67f7e05b2d3f739864ecc31carembc18a85
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-04-07 16:28:34 +08:00
fufesou ac74ed1914 legacy mode, win, fix layout code simulation
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-04-06 17:53:07 +08:00
fufesou 0b417ac479 start --server on gmd wayland, just for communications, no connections will be established
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-03-31 16:42:35 +08:00
Chieh Wang d7dbe41ada better error info 2023-03-20 15:28:14 +08:00
asur4s 2aae2ca513 Refector key click && Clear remapped keycodes 2023-03-18 20:55:35 -07:00
fufesou b733ad9379 refact register_breakdown_handler
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-02-19 10:19:28 +08:00
fufesou b2d13647be translate mode, mac --> win, debug 2
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-02-14 21:42:31 +08:00
fufesou 00867276ed fix wayland input
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-01-10 14:18:25 +08:00
Josh Soref c89e104f3e spelling: regardless
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-01-09 12:59:08 -05:00
Josh Soref 4993635652 spelling: platforms
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-01-09 12:59:08 -05:00
Josh Soref f91daf046a spelling: invocation
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-01-09 12:59:08 -05:00
Josh Soref 69595b7b67 spelling: implementation
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-01-09 12:59:08 -05:00
Josh Soref 53556ba06c spelling: essentially
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-01-09 12:58:33 -05:00
Josh Soref 8c901c2585 spelling: custom
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-01-09 12:58:33 -05:00
sj6219 c5e39f4bbb windows extended key 2023-01-06 20:07:43 +09:00
fufesou 20ba62870e remove unimplemented!
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-01-05 17:52:57 +08:00
fufesou b4feae33bb support linux mouse back/forward
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-01-05 17:47:26 +08:00
fufesou 97cf85d1b7 mouse forward back support on windows
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-01-05 17:47:26 +08:00
fufesou 97718b33a6 remove expect
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2023-01-02 13:11:25 +08:00
fufesou 01ade73304 fix macos sticky fn, https://stackoverflow.com/questions/74938870/sticky-fn-after-home-is-simulated-programmatically-macos
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2022-12-29 14:37:09 +08:00
KG7x 71103886e6 Fix typo 2022-12-25 20:21:13 +03:00
fufesou fff6aad1c5 compile win & macos
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2022-11-25 19:28:43 +08:00
fufesou 9dfa02a702 Fix wayland input after Lock and Wake
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2022-11-25 19:28:43 +08:00
xxrl 260c924010 opt: mac scroll to fast 2022-11-08 23:05:43 +08:00
rustdesk e8182e762d remove another transmute_copy 2022-10-31 23:41:51 +08:00
rustdesk 4c9dadc41a fix transmute crash 2022-10-31 23:03:52 +08:00
fufesou 3c9ac9e4d7 wayland: fix enigo init
Signed-off-by: fufesou <shuanglongchen@yeah.net>
2022-10-17 21:55:26 +08:00
asur4s 2d7cd7c864 Refactor: tfc 2022-09-05 11:50:42 -04:00
asur4s 72d357e14b Refactor get led state 2022-09-05 08:07:13 -04:00
Asura 4421d08384 Delete reset function about enigo 2022-09-01 20:24:50 -07:00
Asura 37dbfcc86d Delete pynput from repo 2022-08-31 23:07:52 -07:00
Asura 25525cda3f Add translte mode in input_service 2022-07-27 20:01:42 -07:00
Asura 1caee4e306 Sync CapsLock and NumLock status in legacy mode. 2022-07-23 08:20:39 -07:00
Asura b3b97ee69a Remove log info 2022-07-23 21:45:00 +08:00