From 42e902a501d07963e4113e965e3dbbb4fb1da121 Mon Sep 17 00:00:00 2001 From: Khoa Vo Date: Fri, 26 Jun 2026 16:47:23 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20revert=20xdotool=20=E2=80=94=20broken=20?= =?UTF-8?q?on=20US=20keyboard,=20backspaces=20were=20after=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - xdotool type depends on keyboard layout for Unicode — fails on US layout - Backspaces were sent AFTER text (wrong order — erased what was just typed) - Reverted to clipboard paste which is layout-independent --- protocol/src/uinput_monitor.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/protocol/src/uinput_monitor.rs b/protocol/src/uinput_monitor.rs index 633dd97..6254f3c 100644 --- a/protocol/src/uinput_monitor.rs +++ b/protocol/src/uinput_monitor.rs @@ -349,7 +349,7 @@ impl UinputInjector { /// best available method: ydotool (uinput) for ASCII, xdotool (X11) or /// clipboard for Unicode. fn inject_replacement_atomic(&self, backspaces: usize, text: &str) -> InjectResult { - // If all ASCII, send keycodes directly — fast and reliable + // If all ASCII, send keycodes directly if text.chars().all(|c| char_to_linux_keycode(c).is_some() || c == '\n') { if backspaces > 0 { for _ in 0..backspaces { let _ = self.send_backspace(); } @@ -361,23 +361,11 @@ impl UinputInjector { return InjectResult::Success; } - // Unicode text: try xdotool first (reliable, no clipboard) - if !std::env::var("WAYLAND_DISPLAY").is_ok() { - let result = std::process::Command::new("xdotool") - .args(["type", "--clearmodifiers", "--delay", "1", text]) - .output(); - if result.map(|o| o.status.success()).unwrap_or(false) { - if backspaces > 0 { - for _ in 0..backspaces { let _ = self.send_backspace(); } - } - return InjectResult::Success; - } - } - - // Fallback: clipboard paste + // Unicode: clipboard paste. Backspaces FIRST, then paste everything at once. if backspaces > 0 { for _ in 0..backspaces { let _ = self.send_backspace(); } } + if self.copy_to_clipboard(text) { self.send_ctrl_v_x11(); }