c - X11 编程 : Get notified if new window appeared?

标签 c x11

使用 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/

相关文章:

c - 从 C 重新路由 stdin 和 stdout

c++ - TCP 数据包有时会合并(并且延迟?)

java - Linux/X Window 系统下的屏幕阅读/鼠标点击?

bash - 我可以在 Cygwin 中使用类似 UNIX 的路径使用什么文件资源管理器?

python - 调用 glfw.init() 后,BadWindow 在 tkinter 中崩溃

无法正确调整 .bmp 图像的大小(CS50 pset 4,调整大小,不太舒服)

c - 如何通过 Asterisk 中的 AGI C 程序将传入调用路由到代理队列

c - 初始化数组的段错误

x11 - 在 Mavericks 上安装 Inkscape

c++ - 如何连接 wxWidgets、GTK2 小部件和 X11 窗口?