x11window-managersxcbewmh

No event received when X11 client sets _NET_WM_STATE_DEMANDS_ATTENTION


I'm building a taskbar for an X11 desktop and so far I've been successful in detecting new and removed windows and changes to window titles and icons.

However, despite setting every event mask I can think of on the client windows, I've been unable to get any events when a test application adds the _NET_WM_STATE_DEMANDS_ATTENTION atom to its _NET_WM_STATE property.

I'm using Qt5 and capturing the incoming X11 events using installNativeEventFilter. However, I've also tried using xprop -spy and I see the same issue there: Even though polling the _NET_WM_STATE property shows the atom being added and removed, no property change event is ever received. Fluxbox also doesn't seem to pick up on it until something else causes it to re-query the window.

My event filter code resembles this:

xcb_generic_event_t* ev = static_cast<xcb_generic_event_t*>(message);
uint32_t type = ev->response_type;
switch (type) {
case XCB_PROPERTY_NOTIFY: {
  xcb_property_notify_event_t* pev =
      reinterpret_cast<xcb_property_notify_event_t*>(ev);
  qDebug() << "property" << pev->window << pev->atom << (int)pev->state;
  break;
/* snip */
default:
  qDebug() << "unrecognized event" << type;
};

My test application uses QApplication::alert() on a timer to assert the attention flag.

Is there some special handling necessary for atom list properties? Am I doomed to poll for changes? I've tried looking at the source code for other window managers but I haven't been able to identify any specific differences.


Solution

  • It turns out that Qt5's native event filter on X11 doesn't pass everything through consistently. I haven't isolated that bug yet, but I wrote my own minimalist xcb event loop on a separate connection to handle window-management activities and it works fine.