使用 X11 库在 C 中编程,有没有办法在新窗口出现时得到通知?我找到了 XSetAfterFunction但它仅用于调试目的......
感谢您的帮助!
海因里希
@编辑:
这段代码解决了我的问题
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;
}
最佳答案
根据内存,您可以使用 XChangeWindowAttributes 来监听来自根窗口的事件,然后根据您对“新窗口已出现”的定义,对 XMapEvent(或 XCreateWindowEvent 或任何事件)采取行动。
关于c - X11 编程 : Get notified if new window appeared?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4088127/