Erik
Erik

Reputation: 12140

X11 Programming: Get notified if new window appeared?

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

Thanks for your help!

Heinrich

@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;
}

Upvotes: 3

Views: 959

Answers (1)

AProgrammer
AProgrammer

Reputation: 52284

From memory, you can use XChangeWindowAttributes to listen to events from the root window, then act on XMapEvent (or XCreateWindowEvent or whateverEvent depending on your definition of "a new window has appeared").

Upvotes: 2

Related Questions