You’re playing a game fullscreen and ALT-TAB to a web browser to look up something. Suddenly the screen is a flickering mess. What’s going on, and how can you stop it from happening?
The particular flickering I am talking about is the type that looks like the graphical frames of the game and the graphical frames of the browser (or whatever application you have switched to) are being interleaved — you end up seeing a flashing mix of both. There are other types of flickering, but this post is not about those.
Many — if not most — games request exclusive access to the display when they run in “Fullscreen” mode. This allows pretty-much the entire compositing step of the graphics pipeline to be skipped and thus improves performance (FPS).
When you ALT-TAB out of a fullscreen game, the game is supposed to gracefully give up its hold of the display. Since no-one is watching any more, it usually stops rendering frames entirely… which is why the thumbnail preview of the game that you see in the ‘task switcher’ thingy is black. However, “gracefully giving up exclusive access to the display” is very platform-specific, so as more and more games are developed using cross-platform development tools (like Unity) you end up with use-cases that are not adequately catered for.
I game on Linux and the vast majority of the games I play are from Steam. So I sometimes come across weird stuff (like the flickering) when a game is developed for, say, Windows, and then ported (or exported) to Linux where they run natively, under WINE, or thanks to Proton. I’m currently running Linux Mint 21 with AMD graphics and the most recent game I experienced ALT-TAB flickering with was with BattleTech. After a bit of messing about, I finally worked out an easy workaround to the problem.
sudo apt install xdotool
- In Preferences > Keyboard > Shortcuts > Custom Shortcuts you want to “Add custom shortcut”, give it a name that means something to you, have it execute the command
xdotool getactivewindow windowminimize, and bind it to an unused key combination.
- There is no step 3 — that’s all there is to it.
By getting the window manager to forcibly take exclusive control of the display away from the game, you no longer rely on the game to do the right thing and voluntarily give it up.
In the above example,
xdotool finds the currently active window and then forcibly minimises it. The process of minimising an application relinquishes exclusive access to the display so you don’t end up with two different programs trying to display graphics at the same time in the same space and the flickering goes away. Problem solved.
So, when I press my shortcut key combination, the game gets minimised, and whatever other application(s) are running get revealed. Nothing weird happens, which is good enough for me… for now. 🙂
Hope that helps!
NB: There are two other graphics modes worth mentioning: “Windowed” and “Windowed, Maximised”. In both cases the game will render its contents into a window frame. In the Windowed mode, this window just appears on your desktop like any other window, can be moved around and changed in size. Windowed, Maximised is just a window that occupies the whole screen, so the content are scaled to fit the whole screen and the frame border is (usually) not visible — but it’s still just a window, and other windows can be stacked in front of it. FPS is lower in both of these modes because the compositing process has to occur. The flickering problem described in this post does not manifest in either of these graphics modes.