We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1940

Summary: Multiple monitors on Linux: Fullscreen minimizes on focus switch to different monitor
Product: SDL Reporter: Gerry JJ <trick>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72, Espionage724, gabomdq, john, k0009000
Version: HG 2.0   
Hardware: x86_64   
OS: Linux   

Description Gerry JJ 2013-07-04 00:50:25 UTC
On a multimonitor system, I'd expect to be able to run an SDL app fullscreen on one monitor while doing other things on another monitor. This is currently impossible with SDL 2, because as soon as SDL detects focus loss, it automatically minimizes the fullscreen window, even if focus went to a window on another monitor.

This can be reproduced using most of the test programs. E.g. run testrendercopyex and hit alt-enter to go fullscreen, then switch to a window on another monitor.

(Ubuntu 13.04 64-bit, Unity desktop, nvidia drivers)
Comment 1 Alex Szpakowski 2013-07-04 07:22:29 UTC
It does the same thing in OS X when you switch focus from a fullscreen-desktop window, it's pretty annoying.

To work around the issue you can disable all minimization on focus loss with: SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");

Also related to unwanted minimization: http://bugzilla.libsdl.org/show_bug.cgi?id=1840
Comment 2 K900 2013-09-14 16:13:54 UTC
How about a patch that adds a new hint to SDL2.1 that limits SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to only triggering if the active window is on the current screen, something like SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS_CURRENT_SCREEN_ONLY (damn, this _needs_ a shorter name)? Need input on that, because it'll be my first SDL patch and I want to get it right the first time. Also, can anyone test what other platforms affected? Also, I assume hints can be limited to some platforms, because MINIMIZE_ON_FOCUS_LOSS doesn't make much sense on mobile either.
Comment 3 K900 2013-09-14 16:17:10 UTC
> SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS to only triggering if the active
> window is on the current screen, something like

*new active window
Comment 4 K900 2013-09-14 17:40:13 UTC
So I tried detecting which screen the window belongs to, and it seems to be very possible with some xcb magic. Python source: http://paste2.org/OkZO0Bg5 (that uses parts of libqtile for readability/writeability/etc, but in the end it's pure xcb). On Windows, it seems to be possible with GetForegroundWindow ( http://msdn.microsoft.com/en-us/library/windows/desktop/ms633505%28v=vs.85%29.aspx ) and MonitorFromWindow ( http://msdn.microsoft.com/en-us/library/dd145064%28v=vs.85%29.aspx ), but that will need more testing because I don't have Windows on this machine. I can't say anything about OS X because I'm too poor to buy a Mac, so any help on the Mac parts is very much welcome.
Comment 5 K900 2013-09-15 06:25:17 UTC
Another idea: how about checking if the focused window overlaps the game window by >= some pixels? That's probably easier than doing screen detection, because there's less math involved and it might be more portable, too.
Comment 6 Gabriel Jacobo 2013-11-11 22:29:38 UTC
This was fixed recently.
Comment 7 John Drinkwater 2013-12-18 14:12:09 UTC
By http://hg.libsdl.org/SDL/rev/255ca6c77e58