I am trying to get information about the window in focus. It seems that I get a correct window id from xcb_get_input_focus_reply_t->focus
: it stays the same for my Eclipse IDE (56623164) and is another for any other window in focus. However, the value length is always 0 for XCB_ATOM_WM_NAME
.
shortened code
cookie = xcb_get_property(c, 0, fr->focus, XCB_ATOM_WM_NAME,
XCB_ATOM_STRING, 0, 0);
if ((reply = xcb_get_property_reply(c, cookie, NULL))) {
int len = xcb_get_property_value_length(reply);
if (len == 0) {
printf("Zero Length\n");
free(reply);
return;
}
printf("WM_NAME is %.*s\n", len, (char*) xcb_get_property_value(reply));
}
Eclipse Debugger
reply xcb_get_property_reply_t * 0x60bd40
response_type uint8_t 1 '\001'
format uint8_t 0 '\0'
sequence uint16_t 2
length uint32_t 0
type xcb_atom_t 0
bytes_after uint32_t 0
value_len uint32_t 0
pad0 unsigned char [12] 0x60bd54
There is no error (I passed and inspected a xcb_generic_error_t
). Do you have any idea what could go wrong? Maybe I should use Xlib instead...
This code works for me, it is in js-ctypes but you can ignore that part and see this for API use:
Sometimes though what is returned by
xcb_get_input_focus_reply_t->focus
is not the window to act on. I have found that sometimes it doesn't have a title, but if you usexcb_query_tree
you can find its parent window probaby has a title: