Fix bug that prevented fast inject from working correctly

This commit is contained in:
Federico Terzi 2020-04-18 20:08:23 +02:00
parent 5a7c6c4572
commit 6ddefd41bf
2 changed files with 6 additions and 3 deletions

View File

@ -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) {

View File

@ -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);