What would be the proper way to get the active window (the one with input focus) with XCB?
reply = xcb_get_input_focus_reply(connection, xcb_get_input_focus(connection), nullptr);
std::cout << "WId: " << reply->focus;
This seems to be work sometimes and sometimes not.
I also saw someone mentioned querying _NET_ACTIVE_WINDOW root window property but I can't figure out how that is done and is it always supported with XCB?
Edit: The approach above with xcb_get_input_focus is only one part, after getting the reply->focus, you need to follow up the parent windows via xcb_query_tree.