XCB allows us to...
- read a window's name (title) via the
WM_NAMEand_NET_WM_NAMEproperties - monitor for changes in window properties via
XCB_EVENT_MASK_PROPERTY_CHANGE
I'm successfully doing both of these. Specifically, here is how I monitor for changes in the _NET_WM_NAME property of all windows (by subscribing to events on the root window):
/* ... */
const uint32_t list[] = { XCB_EVENT_MASK_PROPERTY_CHANGE };
xcb_change_window_attributes(conn, root_window, XCB_CW_EVENT_MASK, &list);
xcb_flush(conn);
xcb_generic_event_t *evt;
while ((evt = xcb_wait_for_event(conn)))
{
if (evt->response_type == XCB_PROPERTY_NOTIFY)
{
xcb_property_notify_event_t *e = (void *) evt;
/* ... print the window name ... */
}
free(evt);
}
/* ... */
This seems to work fine for the most part, but I've noticed that I don't receive an event when I change tabs within my browser, even though that does change the browser window's title.
Am I doing it wrong or is that not possible with XCB?
Credit for the above code mostly goes to this answer on a related question.