简体   繁体   中英

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

I am porting a game to 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. 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. 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. Which will then prevent anything else from intercepting the keyboard. See for example: 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.

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. They had to implement a special overlay to allow stuff like alt-tab to work. You could maybe look in the source code for Steam client to see how they did it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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