2
我與Xlib的玩弄,和我有這樣的事情來檢查事件窗口/子窗口的基礎上:XCheckWindowEvent不返回ClientMessage事件
// Dispatch X11 events in a more friendly format
static inline bool xwin_event(xwin_t *xwin, event_t *evt) {
XEvent event;
if (!XCheckWindowEvent(xwin->xconn->dpy, xwin->window, 0xFFFFFFFF, &event)) {
return false;
}
if (event.type == ClientMessage) {
printf("Got event, wid: %i\n", event.xany.window);
}
}
我在打電話一個循環。我正在建立自己的窗口:
// Define events we want
XSelectInput(xconn->dpy, xwin->window,
KeyPressMask |
ButtonPressMask | ButtonReleaseMask |
EnterWindowMask | LeaveWindowMask |
PointerMotionMask | ExposureMask |
StructureNotifyMask | SubstructureNotifyMask);
// Grab some window manager events
xwin->proto = XInternAtom(xconn->dpy, "WM_PROTOCOLS", 1);
xwin->close = XInternAtom(xconn->dpy, "WM_DELETE_WINDOW", 0);
XSetWMProtocols(xconn->dpy, xwin->window, &xwin->close, 1);
由於某種原因,我從來沒有看到任何ClientMessage事件出現在隊列中。如果我檢查這樣的事情(這不會讓我通過窗口過濾):
if (!XPending(xwin->xconn->dpy)) {
return false;
}
XNextEvent(xwin->xconn->dpy, &event);
它通過就好了。這是一個已知的問題?
該死的,我一直在閱讀文檔http://tinyurl.com/7ywhvbn,這顯然是不完整的,謝謝! – 2012-04-14 16:46:57