X11编程:如果出现新窗口,会收到通知吗?

时间:2010-11-03 14:34:36

标签: c x11

使用X11库在C中编程,有没有办法在新窗口出现时收到通知?我发现XSetAfterFunction但它仅用于调试......

感谢您的帮助!

海因里希

@edit:

此代码解决了我的问题

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

1 个答案:

答案 0 :(得分:2)

从内存中,您可以使用XChangeWindowAttributes来监听根窗口中的事件,然后根据您的“新窗口出现”的定义,对XMapEvent(或XCreateWindowEvent或whateverEvent)执行操作。