Question / Help Replace red screen w/ image when window is minimized

Whenever I leave a game I'm playing to check something on the web or whatever Borderlands 2 and in sure many other games auto minimize, when that occurs OBS displays a red screen because there's nothing to stream cause the game isn't rendering to the screen. Is it possible with some little edit in the source code to show an image file instead of the red screen? I'll hard code it's full path into the code if it's possible but I'm curious about this little issue.
 

ramma

New Member
You can simply add an image as a source in the screen that is just black to avoid this. Then when a game resizes after minimizing (like CS:GO), the image under the xcomposite capture of that window will be shown in the background.
 

NoXPhasma

Member
Whenever I leave a game I'm playing to check something on the web or whatever Borderlands 2 and in sure many other games auto minimize, when that occurs OBS displays a red screen because there's nothing to stream cause the game isn't rendering to the screen. Is it possible with some little edit in the source code to show an image file instead of the red screen? I'll hard code it's full path into the code if it's possible but I'm curious about this little issue.

Try adding this at the end of your ~/.profile file and relogin to your desktop session:
export SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0

This will prevent all games/programs which use SDL to minimize on focus loss.
 
You can simply add an image as a source in the screen that is just black to avoid this. Then when a game resizes after minimizing (like CS:GO), the image under the xcomposite capture of that window will be shown in the background.
have you tried this because I don't think that will work. i already have an image in the background, my base layer (lowest in order) is my overlay. when the game auto-minimizes the red square is just the source of the game, it's not the entire stream. so i basically already have a black image below the game and it still shows a red area where the game normally shows.

I'll try what NoXPhasma suggested and get back to everyone.
 

ramma

New Member
@ubuntuaddicted I've definitely tried it, and it's working for me. You can see in the first ~10 seconds of this recording I tab in and out twice, where I've got just a black image as the source directly under the game capture. http://www.twitch.tv/ramma_/b/580889871

I also use the SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 as a launch option, but CS:GO started ignoring it a few updates ago.
 

NoXPhasma

Member
I also use the SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 as a launch option, but CS:GO started ignoring it a few updates ago.
I have that in my ~/.profile file and CS:GO doesn't get minimized when I loose focus:
Unbenannt.jpg
 
@ubuntuaddicted I've definitely tried it, and it's working for me. You can see in the first ~10 seconds of this recording I tab in and out twice, where I've got just a black image as the source directly under the game capture. http://www.twitch.tv/ramma_/b/580889871

I also use the SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 as a launch option, but CS:GO started ignoring it a few updates ago.
when I view my ~/.profile file I see the following
Code:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
do i have to add it before the "fi" line or after that line? what's weird is that I already have a black background set and when I tab out of the game just a red box is left from where borderlands 2 was. do you mean add another image on top of my image I already use as my overlay and make it the same size as the game window within obs and then make it on top of the overlay layer but under the game layer?
 

NoXPhasma

Member
Add it just in a new line at the end, my content looks like this:
Code:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

export SDL_VIDEO_FULLSCREEN_DISPLAY=0
export SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0
 

NoXPhasma

Member
looks minimized to me, what you're looking at is the steam overlay not CS:GO (at least that's what I see)
That's not the Steam Overlay, that's the CS:GO main menu oO

Trust me, whenever I leave a game with my mouse, I have two monitors, and focus another window, the game keeps open (not minimized).
 

leonhard

Developer
When a window becomes unavailable depends on the window manager and the configuration of it. Some will stop drawing the window once it is minimized, some when it's on another desktop etc.
You might be able to configure your window manager to keep redrawing windows even if they are hidden.
For me on KDE windows will work with xcomposite regardless of where they are or if they are minimized. I think this option on KDE is somewhere in workspace settings: "keep preview images for all windows" or something along those lines.
 
i edited my ~/.profile file by adding that line and now when I try to alt-tab to a window that's underneath the game it doesn't show up. is that what the line does, makes it so sdl_video screen are always on top? i think it's working since when I alt-tab to something else borderlands tps is still there and I can't drag another window over it, it just goes behind the game. THANKS everyone
 

NoXPhasma

Member
For me it makes no difference if a window is in front/focused or not when I grab it with xcomposite. I'm using Compiz as window manager. I haven't tried it with minimized windows yet. Compiz has the option "keep preview images for all windows" too, and it's activated here.

Not sure if this is the what makes the difference, and how it works on other window managers.
 

NoXPhasma

Member
i edited my ~/.profile file by adding that line and now when I try to alt-tab to a window that's underneath the game it doesn't show up. is that what the line does, makes it so sdl_video screen are always on top? i think it's working since when I alt-tab to something else borderlands tps is still there and I can't drag another window over it, it just goes behind the game. THANKS everyone
Uhhm, no, I can drag other windows in top of games too. The line just change the behaviour of SDL games to not minimize when they loose focus. That you can't move windows in top of your game, seems to be related to your window manager. Here is a proof:
Unbenannt.jpg
 
im using XFCE with compton for my compositing, before setting the no loss focus within my ~/.profile file when I would alt-tab out of the game it would auto-minimize, now it does not auto-minimize but like I said i can't get any other window to be on top of the game. it's not a big deal since i have another monitor.

what does this line do?
export SDL_VIDEO_FULLSCREEN_DISPLAY=0

because my monitor i game on is actually at +1680,0 since X's 0,0 is always the farthest left monitor and the monitor I want to game on is on the right of my first monitor. So would I set that fullscreen display to 1?
 

NoXPhasma

Member
SDL1 games can't really handle multiple monitor setups and will run the game over all monitors maximized. This option is a fix for that to say SDL1 games which monitor to use and to ignore the other monitors. It has no impact on SDL2 games, so it's save to use that global.

You can change 0 with the number of your monitor you want to run the game on.

Again, this has no impact to newer games which use SDL2, like CS:GO or Unity based games. For that you need a different solution, you can take a look on devilspie2, with that you can set fixed window positions and much more.
 
Last edited:

NoXPhasma

Member
Are you sure your games aren't in windowed fullscreen? That's how the game behaves for me in windowed full screen, but the SDL_VIDEO_FULLSCREEN_DISPLAY=0 option just isn't working for me.
You should read what I write, SDL_VIDEO_FULLSCREEN_DISPLAY=0 has absolutely nothing to do with keeping a game in front, or not minimized. This option is ONLY for older SDL1 games, to force them to use only on monitor. And the 0 says which monitor you want. 0 is the first monitor, 1 the second ...

And yes I'm more than sure that SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0 will prevent minimizing of all SDL2 games no matter if they are in fullscreen, window or fullscreen window. Of course, you can still minimize those games on your own, this option doesn't change that, of course. If SDL2 game still get minimized on your system, you should take a look at your window manager.

And if you still think this can't work, search on Google for those environment variables.
 
at least i've now got it so that when I alt-tab out of my game there's no red screen within obs anymore (because the game doesn't auto-minimize anymore it just stays there) BUT now i can't get any window over the top of the game. it's possible something is set incorrectly with my compositing engine which is compton. compton provides me a tear free desktop which is why i use it. previous to using compton i had tearing while watching videos on vlc and tearing in minecraft. i obviously disabled XFCE's default componsiting engine. I'll have to dig into compton's settings because currently i'm just using a .conf from someone's tutorial for setting it up which is here: http://ubuntuforums.org/showthread.php?t=2144468

Thanks for the help guys!!
 
Top