How do I stop fullscreen games from minimizing when I click on another window on my second monitor?

I am trying to play a game that doesn't have a borderless window mode, and I don't want to use the normal windowed mode on the game.

I use two monitors, one as a large main monitor, and one as something to keep track of chats, wikis, and the like. Most games I play have an option to keep the full-screen game on top (borderless window mode) while I play, but, for the games that don't have this feature, it can be pretty frustrating.

Is there any way to force the game to stay maximized if I click on my second monitor?

4 Answers

I don't have enough rep to comment on gunix's answer, but someone asked for context, so I'll just write my own answer.

This behavior is generally caused by SDL, a commonly used library for creating OpenGL contexts for games to render things into. This commit to libSDL2 in 2012 adds an environment variable, SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS, which, as the name suggests, controls whether or not the game will minimize itself if it loses window focus.

To stop this behavior, you need to set this environment variable to 0. There are a few ways to do this:

  • Modify your local environment files, located somewhere in your home directory, perhaps .profile or .xprofile; .bashrc would set it for your Bash shell but that might not be helpful if you're logged in via xdm or one of its many alternatives. This would affect all games using SDL and run as your user.
  • Modify your global environment files, usually /etc/profile or /etc/environment. Compared to the environment files in your home directory, this is not a recommended choice, but if you're the only user on the system and changes to .profile don't seem to apply even after logging out and back in again, this is a second thing to try.

For both of the above options, you would add this line:

 export SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0
  • If this is a Steam game, you can add it to your launch options:

     SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 %command%
  • If this isn't a Steam game, but you still want to change it for this one game only, you could create a launch_game.sh file in the same directory as the game's main executable:

     #!/bin/sh export SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 ./SomeGame "$@"
4

Add the following line:

export SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0

to the file /etc/environment and reboot after that.

1

Many games can be set to "borderless window", "windowed borderless" or something similar in the graphics settings. After you set it, the game will still be using the entire screen, but it will be considered a regular window by the OS. I think this can prevent the game being minimized when you click in the second screen.

1

If you're struggling to find your local environment variables file, there's an easy way to add a new variable through control panel.

Follow these steps from

  1. In Search, search for and then select: System (Control Panel)
  2. Click the Advanced system settings link.
  3. Click Environment Variables.
  4. In the section System Variables find the PATH environment variable and select it.

Once there select "new" and add the variable SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS with a value of 0 and save.

This should solve your issue without having to edit the file directly or use command line if you can't find the file.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like