开发者

X11 Programming: Get notified if new window appeared?

开发者 https://www.devze.com 2023-01-23 13:01 出处:网络
programming in C with the X11 library, is there a way to get notified if a new windowhas appeared? I found XSetAfterFunction but its intended for debugging purposes only ...

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 = SubstructureNoti开发者_如何学JAVAfyMask | StructureNotifyMask;

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

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

return 0;
}


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").

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号