diff --git a/native/liblinuxbridge/bridge.cpp b/native/liblinuxbridge/bridge.cpp index 71706d9..5db95c7 100644 --- a/native/liblinuxbridge/bridge.cpp +++ b/native/liblinuxbridge/bridge.cpp @@ -340,7 +340,7 @@ void fast_send_string(const char * string) { fast_enter_text_window(xdo_context, focused, string, 1); } -void _fast_send_keycode_to_focused_window(int KeyCode, int32_t count) { +void _fast_send_keycode_to_focused_window(int KeyCode, int32_t count, int32_t delay) { int keycode = XKeysymToKeycode(xdo_context->xdpy, KeyCode); Window focused; @@ -350,13 +350,18 @@ void _fast_send_keycode_to_focused_window(int KeyCode, int32_t count) { for (int i = 0; i 0) { + usleep(delay * 1000); + XFlush(xdo_context->xdpy); + } } XFlush(xdo_context->xdpy); } void fast_send_enter() { - _fast_send_keycode_to_focused_window(XK_Return, 1); + _fast_send_keycode_to_focused_window(XK_Return, 1, 0); } void delete_string(int32_t count) { @@ -365,8 +370,8 @@ void delete_string(int32_t count) { } } -void fast_delete_string(int32_t count) { - _fast_send_keycode_to_focused_window(XK_BackSpace, count); +void fast_delete_string(int32_t count, int32_t delay) { + _fast_send_keycode_to_focused_window(XK_BackSpace, count, delay); } void left_arrow(int32_t count) { @@ -376,7 +381,7 @@ void left_arrow(int32_t count) { } void fast_left_arrow(int32_t count) { - _fast_send_keycode_to_focused_window(XK_Left, count); + _fast_send_keycode_to_focused_window(XK_Left, count, 0); } void trigger_paste() { diff --git a/native/liblinuxbridge/bridge.h b/native/liblinuxbridge/bridge.h index e44f119..9402bf0 100644 --- a/native/liblinuxbridge/bridge.h +++ b/native/liblinuxbridge/bridge.h @@ -75,7 +75,7 @@ extern "C" void delete_string(int32_t count); /* * Send the backspace keypress, *count* times using a faster inject method */ -extern "C" void fast_delete_string(int32_t count); +extern "C" void fast_delete_string(int32_t count, int32_t delay); /* * Send an Enter key press diff --git a/src/bridge/linux.rs b/src/bridge/linux.rs index 63ee91c..a3f96f7 100644 --- a/src/bridge/linux.rs +++ b/src/bridge/linux.rs @@ -49,7 +49,7 @@ extern { pub fn trigger_copy(); pub fn fast_send_string(string: *const c_char); - pub fn fast_delete_string(count: i32); + pub fn fast_delete_string(count: i32, delay: i32); pub fn fast_left_arrow(count: i32); pub fn fast_send_enter(); } \ No newline at end of file diff --git a/src/keyboard/linux.rs b/src/keyboard/linux.rs index 4a9fd2a..a33ceba 100644 --- a/src/keyboard/linux.rs +++ b/src/keyboard/linux.rs @@ -93,7 +93,7 @@ impl super::KeyboardManager for LinuxKeyboardManager { fn delete_string(&self, active_config: &Configs, count: i32) { unsafe { if active_config.fast_inject { - fast_delete_string(count); + fast_delete_string(count, active_config.backspace_delay); }else{ delete_string(count) }