fix: revert xdotool — broken on US keyboard, backspaces were after type
- 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
This commit is contained in:
parent
540c576591
commit
42e902a501
1 changed files with 3 additions and 15 deletions
|
|
@ -349,7 +349,7 @@ impl UinputInjector {
|
||||||
/// best available method: ydotool (uinput) for ASCII, xdotool (X11) or
|
/// best available method: ydotool (uinput) for ASCII, xdotool (X11) or
|
||||||
/// clipboard for Unicode.
|
/// clipboard for Unicode.
|
||||||
fn inject_replacement_atomic(&self, backspaces: usize, text: &str) -> InjectResult {
|
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 text.chars().all(|c| char_to_linux_keycode(c).is_some() || c == '\n') {
|
||||||
if backspaces > 0 {
|
if backspaces > 0 {
|
||||||
for _ in 0..backspaces { let _ = self.send_backspace(); }
|
for _ in 0..backspaces { let _ = self.send_backspace(); }
|
||||||
|
|
@ -361,23 +361,11 @@ impl UinputInjector {
|
||||||
return InjectResult::Success;
|
return InjectResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unicode text: try xdotool first (reliable, no clipboard)
|
// Unicode: clipboard paste. Backspaces FIRST, then paste everything at once.
|
||||||
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 {
|
if backspaces > 0 {
|
||||||
for _ in 0..backspaces { let _ = self.send_backspace(); }
|
for _ in 0..backspaces { let _ = self.send_backspace(); }
|
||||||
}
|
}
|
||||||
return InjectResult::Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fallback: clipboard paste
|
|
||||||
if backspaces > 0 {
|
|
||||||
for _ in 0..backspaces { let _ = self.send_backspace(); }
|
|
||||||
}
|
|
||||||
if self.copy_to_clipboard(text) {
|
if self.copy_to_clipboard(text) {
|
||||||
self.send_ctrl_v_x11();
|
self.send_ctrl_v_x11();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue