Add option to delay backspace presses on Linux. See #248
This commit is contained in:
parent
171c18873e
commit
eae013d16f
|
@ -340,7 +340,7 @@ void fast_send_string(const char * string) {
|
||||||
fast_enter_text_window(xdo_context, focused, string, 1);
|
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);
|
int keycode = XKeysymToKeycode(xdo_context->xdpy, KeyCode);
|
||||||
|
|
||||||
Window focused;
|
Window focused;
|
||||||
|
@ -350,13 +350,18 @@ void _fast_send_keycode_to_focused_window(int KeyCode, int32_t count) {
|
||||||
for (int i = 0; i<count; i++) {
|
for (int i = 0; i<count; i++) {
|
||||||
fast_send_event(xdo_context, focused, keycode, 1);
|
fast_send_event(xdo_context, focused, keycode, 1);
|
||||||
fast_send_event(xdo_context, focused, keycode, 0);
|
fast_send_event(xdo_context, focused, keycode, 0);
|
||||||
|
|
||||||
|
if (delay > 0) {
|
||||||
|
usleep(delay * 1000);
|
||||||
|
XFlush(xdo_context->xdpy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XFlush(xdo_context->xdpy);
|
XFlush(xdo_context->xdpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fast_send_enter() {
|
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) {
|
void delete_string(int32_t count) {
|
||||||
|
@ -365,8 +370,8 @@ void delete_string(int32_t count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fast_delete_string(int32_t count) {
|
void fast_delete_string(int32_t count, int32_t delay) {
|
||||||
_fast_send_keycode_to_focused_window(XK_BackSpace, count);
|
_fast_send_keycode_to_focused_window(XK_BackSpace, count, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
void left_arrow(int32_t count) {
|
void left_arrow(int32_t count) {
|
||||||
|
@ -376,7 +381,7 @@ void left_arrow(int32_t count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void fast_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() {
|
void trigger_paste() {
|
||||||
|
|
|
@ -75,7 +75,7 @@ extern "C" void delete_string(int32_t count);
|
||||||
/*
|
/*
|
||||||
* Send the backspace keypress, *count* times using a faster inject method
|
* 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
|
* Send an Enter key press
|
||||||
|
|
|
@ -49,7 +49,7 @@ extern {
|
||||||
pub fn trigger_copy();
|
pub fn trigger_copy();
|
||||||
|
|
||||||
pub fn fast_send_string(string: *const c_char);
|
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_left_arrow(count: i32);
|
||||||
pub fn fast_send_enter();
|
pub fn fast_send_enter();
|
||||||
}
|
}
|
|
@ -93,7 +93,7 @@ impl super::KeyboardManager for LinuxKeyboardManager {
|
||||||
fn delete_string(&self, active_config: &Configs, count: i32) {
|
fn delete_string(&self, active_config: &Configs, count: i32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
if active_config.fast_inject {
|
if active_config.fast_inject {
|
||||||
fast_delete_string(count);
|
fast_delete_string(count, active_config.backspace_delay);
|
||||||
}else{
|
}else{
|
||||||
delete_string(count)
|
delete_string(count)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user