From 6ddefd41bf1856beeafe3302752593bb70d4894e Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sat, 18 Apr 2020 20:08:23 +0200 Subject: [PATCH] Fix bug that prevented fast inject from working correctly --- native/liblinuxbridge/bridge.cpp | 6 +++++- native/liblinuxbridge/fast_xdo.cpp | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/native/liblinuxbridge/bridge.cpp b/native/liblinuxbridge/bridge.cpp index 2934ca9..417b8b6 100644 --- a/native/liblinuxbridge/bridge.cpp +++ b/native/liblinuxbridge/bridge.cpp @@ -311,7 +311,11 @@ void fast_send_string(const char * string) { // and inject a key_release event so that they can be further registered. release_all_keys(); - xdo_enter_text_window(xdo_context, CURRENTWINDOW, string, 1); + Window focused; + int revert_to; + XGetInputFocus(xdo_context->xdpy, &focused, &revert_to); + + fast_enter_text_window(xdo_context, focused, string, 1); } void _fast_send_keycode_to_focused_window(int KeyCode, int32_t count) { diff --git a/native/liblinuxbridge/fast_xdo.cpp b/native/liblinuxbridge/fast_xdo.cpp index 576a20f..0d60fcb 100644 --- a/native/liblinuxbridge/fast_xdo.cpp +++ b/native/liblinuxbridge/fast_xdo.cpp @@ -27,7 +27,6 @@ void fast_send_key(const xdo_t *xdo, Window window, charcodemap_t *key, /* Properly ensure the modstate is set by finding a key * that activates each bit in the modifier state */ int mask = modstate | key->modmask; - int use_xtest = 0; /* Since key events have 'state' (shift, etc) in the event, we don't * need to worry about key press ordering. */ @@ -37,7 +36,7 @@ void fast_send_key(const xdo_t *xdo, Window window, charcodemap_t *key, xk.keycode = key->code; xk.state = mask | (key->group << 13); xk.type = (is_press ? KeyPress : KeyRelease); - XSendEvent(xdo->xdpy, xk.window, True, KeyPressMask, (XEvent *)&xk); + XSendEvent(xdo->xdpy, xk.window, True, 0, (XEvent *)&xk); /* Skipping the usleep if delay is 0 is much faster than calling usleep(0) */ XFlush(xdo->xdpy);