diff --git a/native/liblinuxbridge/bridge.cpp b/native/liblinuxbridge/bridge.cpp index 421af94..7aff24f 100644 --- a/native/liblinuxbridge/bridge.cpp +++ b/native/liblinuxbridge/bridge.cpp @@ -295,6 +295,10 @@ void send_string(const char * string) { xdo_enter_text_window(xdo_context, CURRENTWINDOW, string, 1000); } +void send_enter() { + xdo_send_keysequence_window(xdo_context, CURRENTWINDOW, "Return", 1000); +} + void delete_string(int32_t count) { for (int i = 0; i, U: UIMa match backend { BackendType::Inject => { - // Send the expected string. On linux, newlines are managed automatically - // while on windows and macos, we need to emulate a Enter key press. + // To handle newlines, substitute each "\n" char with an Enter key press. + let splits = target_string.split('\n'); - if cfg!(target_os = "linux") { - self.keyboard_manager.send_string(&target_string); - }else{ - // To handle newlines, substitute each "\n" char with an Enter key press. - let splits = target_string.split('\n'); - - for (i, split) in splits.enumerate() { - if i > 0 { - self.keyboard_manager.send_enter(); - } - - self.keyboard_manager.send_string(split); + for (i, split) in splits.enumerate() { + if i > 0 { + self.keyboard_manager.send_enter(); } + + self.keyboard_manager.send_string(split); } }, BackendType::Clipboard => { diff --git a/src/keyboard/linux.rs b/src/keyboard/linux.rs index 04c3c3a..03d55ba 100644 --- a/src/keyboard/linux.rs +++ b/src/keyboard/linux.rs @@ -35,7 +35,9 @@ impl super::KeyboardManager for LinuxKeyboardManager { } fn send_enter(&self) { - // On linux this is not needed, so NOOP + unsafe { + send_enter(); + } } fn trigger_paste(&self, shortcut: &PasteShortcut) {