[Xcb] Sending Keyboard Events with XTest

icy_flurry Icy_Flurry at protonmail.com
Thu Jan 6 15:58:54 UTC 2022


Hi,

I'm trying to send keyboard events with XTest, but for some reason, the release event I send does not seem to have any effect unless I call `xcb_request_check()` on either one of the returned cookies. My code is as follows:

```c
#include <xcb/xcb.h>
#include <xcb/xtest.h>
#include <xcb/xcb_keysyms.h>
#include <stdlib.h>

int main(){
xcb_connection_t* conn = xcb_connect(NULL,NULL);
xcb_key_symbols_t* keysyms = xcb_key_symbols_alloc(conn);
xcb_keycode_t* keycode = xcb_key_symbols_get_keycode(keysyms,'a');
xcb_key_symbols_free(keysyms);
xcb_test_fake_input(conn,XCB_KEY_PRESS,*keycode,XCB_CURRENT_TIME,XCB_NONE,0,0,0);
xcb_test_fake_input(conn,XCB_KEY_RELEASE,*keycode,XCB_CURRENT_TIME,XCB_NONE,0,0,0);
xcb_flush(conn);
free(keycode);
xcb_disconnect(conn);
}
```
This continues typing 'a' until I press a key manually. Now, if I store the returned cookie and call `xcb_request_check()`, it just presses it once, as I expect. How can I fix this? Also, are there more complete docs for using XTest with XCB?

Thanks in advance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20220106/54233538/attachment.htm>


More information about the Xcb mailing list