简体   繁体   English

如何为我的Linux游戏禁用gnome窗口管理器键盘快捷键?

[英]How can I disable gnome window manager keyboard shortcuts for my linux game?

I am porting a game to linux. 我正在将游戏移植到Linux。 It is a complex game and has lots of keyboard and mouse shortcuts for finer control. 这是一个复杂的游戏,具有许多键盘和鼠标快捷键,可以进行更好的控制。 One of the shortcuts utilises alt and right mouse click, which conflicts with some window manager functionality - namely a context menu appears on some machines. 快捷方式之一是利用alt和鼠标右键单击,这与某些窗口管理器功能冲突-即在某些计算机上显示上下文菜单。 I have tried disabling this at runtime by collecting the output of "gsettings get org.gnome.desktop.wm.preferences mouse-button-modifier" and altering it if a conflict is detected, but this is very hacky and only works in a few cases. 我尝试通过收集“ gsettings get org.gnome.desktop.wm.preferences mouse-button-modifier”的输出在运行时禁用此功能,并在检测到冲突时对其进行更改,但这非常麻烦,并且仅在少数情况下有效案例。 Does anybody know if there is a better, more reliable way of doing this - preferably a way of disabling all the shortcuts when my game window is active. 有人知道是否有更好,更可靠的方法来执行此操作-最好是在我的游戏窗口处于活动状态时禁用所有快捷方式的方法。

You can use some X Server code to grab the keyboard and lock it to the apps window. 您可以使用一些X Server代码来抓住键盘并将其锁定到应用程序窗口。 Which will then prevent anything else from intercepting the keyboard. 这样可以防止其他任何东西拦截键盘。 See for example: https://tronche.com/gui/x/xlib/input/XGrabKeyboard.html 参见例如: https : //tronche.com/gui/x/xlib/input/XGrabKeyboard.html

The disadvantage of taking a heavy handed approach like this is it breaks things like being able to Alt+Tab out of your full-screen window. 采取这种笨拙方法的缺点是,它会破坏诸如Alt + Tab退出全屏窗口的功能。

LWN has an article about all the tricks Valve went through to get Steam to work in Linux ( http://lwn.net/Articles/611969/ ) Valve went as far as to use LD_PRELOAD in places. LWN上有一篇文章,介绍了Valve使Steam在Linux中工作的所有技巧( http://lwn.net/Articles/611969/)Valve甚至在某些地方使用LD_PRELOAD。 They had to implement a special overlay to allow stuff like alt-tab to work. 他们必须实现特殊的覆盖,以允许alt-tab之类的东西正常工作。 You could maybe look in the source code for Steam client to see how they did it. 您也许可以查看Steam客户端的源代码,以了解他们是如何做到的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM