2
我想要創建「InputOnly」窗口,該窗口應該是不可見的並且需要輸入,但是當運行代碼時,我的InputOnly窗口確實收到任何事件。 我想把我的注意力放在其他窗口上,並且仍然得到輸入。我怎樣才能實現它?創建InputOnly窗口
#include <X11/Xlib.h>
#include <iostream>
int main(void) {
Display *dsp;
Window root;
Window windows[2];
XEvent ev;
int i = 0;
dsp = XOpenDisplay(NULL);
root = RootWindow(dsp, DefaultScreen(dsp));
windows[i] = XCreateSimpleWindow(
dsp,
root,
0, 0, 200, 200,
1,
BlackPixel(dsp, DefaultScreen(dsp)),
WhitePixel(dsp, DefaultScreen(dsp))
);
XSelectInput(dsp, windows[i], 0);
XMapWindow(dsp, windows[i]);
++i;
XSetWindowAttributes at;
at.event_mask = KeyPressMask;
windows[i] = XCreateWindow(
dsp,
root,
10,10,200,200,
0,
CopyFromParent,
InputOnly,
0,
0,
&at
);
XSelectInput(dsp, windows[i], KeyPressMask);
//XMapWindow(dsp, windows[i]);
while(1) {
XNextEvent(dsp, &ev);
std::cout << "foo" << std::endl;
}
return 0;
}