如何在 X-Windows 中改变焦点?
我正在为 Linux 开发基于 Motif 的旧应用程序。 我希望能够以编程方式更改应用程序的活动窗口。 我可以使用 XSetInputFocus() 函数重定向输入,键盘输入开始转到那里,但 XReconfigureWMWindow() 和 XRaiseWindow() 函数不起作用。
我读到窗口管理器尝试阻止此行为,因此尝试禁用配置重定向,但这也不起作用。 有什么想法如何在窗口堆栈顶部制作我自己的窗口之一吗?
I am working on old Motif-based application for Linux. I want to be able to programmatically change the active window of our application. I can redirect the input by using XSetInputFocus() function and the keyboard input start to go there, but XReconfigureWMWindow() and XRaiseWindow() functions just don't work.
I've read that Window Managers try to stop this behaviour, so tried to disable configure redirection, but this doesn't work either. Any ideas how to make one of my own windows on top of the window stack?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一个名为 wmctrl 的小程序可用(至少在 Debian/Ubuntu 中它是标准的发行版)它能够在窗口和桌面上执行许多操作,并处理大量的窗口管理器。 我建议测试它是否适用于您的环境,如果可以,请查看其来源。
There is a tiny program called wmctrl available (at least in Debian/Ubuntu it is in standard distribution) which is able to perform many operations on windows and desktops, and handles plenty of window managers. I'd suggest testing whether it works in your environment, and if so, peeking at its sources.
您可能会发现这个问题的答案取决于用户正在使用的窗口管理器,甚至取决于他们为窗口管理器提供的设置。 我喜欢将我的窗口管理器设置为“焦点跟随鼠标”,这意味着您无法将焦点发送到我没有将鼠标放在上面的窗口,除非您也在那里扭曲鼠标(该函数称为 XWarpMouse ?)。
You may find the answer to this is dependent on the Window Manager the user is using, or even what settings they've given to the Window Manager. I like to set my Window Managers to do "focus follows mouse", which means you can't send the focus to a window that I haven't put my mouse on, unless you also warp the mouse there (is that function called XWarpMouse?).