Add option to delay injected text on Linux. See #248
This commit is contained in:
parent
eae013d16f
commit
23939a59b3
|
@ -325,7 +325,7 @@ void fast_release_all_keys() {
|
|||
XFlush(xdo_context->xdpy);
|
||||
}
|
||||
|
||||
void fast_send_string(const char * string) {
|
||||
void fast_send_string(const char * string, int32_t delay) {
|
||||
// It may happen that when an expansion is triggered, some keys are still pressed.
|
||||
// This causes a problem if the expanded match contains that character, as the injection
|
||||
// will not be able to register that keypress (as it is already pressed).
|
||||
|
@ -337,7 +337,12 @@ void fast_send_string(const char * string) {
|
|||
int revert_to;
|
||||
XGetInputFocus(xdo_context->xdpy, &focused, &revert_to);
|
||||
|
||||
fast_enter_text_window(xdo_context, focused, string, 1);
|
||||
int actual_delay = 1;
|
||||
if delay > 0 {
|
||||
actual_delay = delay * 1000;
|
||||
}
|
||||
|
||||
fast_enter_text_window(xdo_context, focused, string, actual_delay);
|
||||
}
|
||||
|
||||
void _fast_send_keycode_to_focused_window(int KeyCode, int32_t count, int32_t delay) {
|
||||
|
|
|
@ -65,7 +65,7 @@ extern "C" void send_string(const char * string);
|
|||
/*
|
||||
* Type the given string by simulating Key Presses using a faster inject method
|
||||
*/
|
||||
extern "C" void fast_send_string(const char * string);
|
||||
extern "C" void fast_send_string(const char * string, int32_t delay);
|
||||
|
||||
/*
|
||||
* Send the backspace keypress, *count* times.
|
||||
|
|
|
@ -215,8 +215,7 @@ int fast_enter_text_window(const xdo_t *xdo, Window window, const char *string,
|
|||
key.needs_binding = 0;
|
||||
fast_send_keysequence_window_list_do(xdo, window, &key, 1, False, NULL, delay / 2);
|
||||
|
||||
/* XXX: Flush here or at the end? or never? */
|
||||
//XFlush(xdo->xdpy);
|
||||
XFlush(xdo->xdpy);
|
||||
} /* walk string generating a keysequence */
|
||||
|
||||
//free(keys);
|
||||
|
|
|
@ -48,7 +48,7 @@ extern {
|
|||
pub fn trigger_ctrl_alt_paste();
|
||||
pub fn trigger_copy();
|
||||
|
||||
pub fn fast_send_string(string: *const c_char);
|
||||
pub fn fast_send_string(string: *const c_char, delay: i32);
|
||||
pub fn fast_delete_string(count: i32, delay: i32);
|
||||
pub fn fast_left_arrow(count: i32);
|
||||
pub fn fast_send_enter();
|
||||
|
|
|
@ -63,6 +63,7 @@ fn default_enable_passive() -> bool { false }
|
|||
fn default_enable_active() -> bool { true }
|
||||
fn default_backspace_limit() -> i32 { 3 }
|
||||
fn default_backspace_delay() -> i32 { 0 }
|
||||
fn default_inject_delay() -> i32 { 0 }
|
||||
fn default_restore_clipboard_delay() -> i32 { 300 }
|
||||
fn default_exclude_default_entries() -> bool {false}
|
||||
fn default_secure_input_watcher_enabled() -> bool {true}
|
||||
|
@ -172,6 +173,9 @@ pub struct Configs {
|
|||
#[serde(default = "default_backspace_delay")]
|
||||
pub backspace_delay: i32,
|
||||
|
||||
#[serde(default = "default_inject_delay")]
|
||||
pub inject_delay: i32,
|
||||
|
||||
#[serde(default = "default_matches")]
|
||||
pub matches: Vec<Match>,
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ impl super::KeyboardManager for LinuxKeyboardManager {
|
|||
match res {
|
||||
Ok(cstr) => unsafe {
|
||||
if active_config.fast_inject {
|
||||
fast_send_string(cstr.as_ptr());
|
||||
fast_send_string(cstr.as_ptr(), active_config.inject_delay);
|
||||
}else{
|
||||
send_string(cstr.as_ptr());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user