X11 Programming: receive notification if a new window appears?

C programming with the X11 library, is there a way to get notified if a new window appears? I found XSetAfterFunction , but is for debugging purposes only ...

Thank you for your help!

Henry

@edit:

This code solves my problem

int main() {    
Display* display = XOpenDisplay(":2");

XSetWindowAttributes attributes;
attributes.event_mask = SubstructureNotifyMask | StructureNotifyMask;

XChangeWindowAttributes(display, 0x100, CWEventMask, &attributes);

while (true) {
    XEvent event;
    XNextEvent(display, &event);
    std::cout << "Event occured" << std::endl;
}

return 0;
}
+3
source share
1 answer

From memory, you can use XChangeWindowAttributes to listen for events from the root window, and then act in XMapEvent (either XCreateWindowEvent or whateverEvent depending on your definition of β€œa new window has appeared”).

+2
source

Source: https://habr.com/ru/post/1772859/


All Articles