如何使用 XLib 创建映射但不可见的窗口?
我正在一个游戏项目中开发一个基于Linux的I/O验证工具。它是用 C++ 编写的,并且由于使用与我们的游戏相同的 I/O 模块,因此它基于 OIS 1.2。因此,虽然我需要的只是在控制台上打印用户的输入,但我仍然需要为 OIS 创建一个窗口。
所以我的问题来了:如何创建一个映射窗口,同时它仍然不可见并处理键盘事件?
我无法取消映射窗口,因为它不再处理任何键盘事件。我也找不到显示/隐藏窗口的功能。(也许我搜索的方向错误......)
我的小工具现在工作正常,除了有一个愚蠢的顶级空窗口需要集中处理键盘活动...
欢迎任何建议。
谢谢!!!
I'm working on a I/O verification tool based on Linux in a game project. It is written in C++, and,since using the same I/O module as our game, it's based on OIS 1.2. Thus, though all I need is to print users' inputs on the console, I still need to create a window for OIS.
So here comes my question: How can I create a mapped window while it is still invisible and processes keyboard events?
I can't unmapped the window in that it won't process any keyboard event anymore. I also can't find function for show/hide a window.(maybe I search through a wrong diretion...)
My little tool works fine now except there is a stupid top-level empty window which needs to be focused for processing keyboard events...
Any advise is welcomed.
Thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
阅读这篇文章后: Linux/X11 输入库,无需创建窗口,
我意识到我的问题是我误解了 X11 的哲学。我需要做的只是将根窗口句柄传递给 OIS,并将 x11_grabkeyboard 标志设置为 true。唯一的缺点是也许我很难用 gdb 调试我的程序,因为键盘被抓住了......
虽然我的情况解决了,但还剩下一件事。
我读过的每一篇文章都说InputOnly窗口不可见并且能够处理输入事件,而我的InputOnly窗口在映射后绝对可见......
也许这是我的Linux,或者又是一个误解......
After reading this post: Linux/X11 input library without creating a window,
I realized my problem was that I misunderstood the philosophy of X11. All I need to do is simply pass the root window handle to OIS, and set the x11_grabkeyboard flag as true. The only drawback is maybe I can hardly debug my program with gdb since the keyboard is grabbed...
Though my situation is solved, there is one thing left.
Every article I read said an InputOnly window won't be visible and is capable for handling input events, while my InputOnly window is absolutely visible after mapped...
Maybe it's my Linux, or again, a misunderstanding...