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 5106 - SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS has an insane default value for linux
Summary: SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS has an insane default value for linux
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.12
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.14
Depends on:
Blocks:
 
Reported: 2020-04-22 23:50 UTC by Stephen Cameron
Modified: 2020-06-29 12:46 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Cameron 2020-04-22 23:50:52 UTC
SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS has a bad default for linux.

The default is 1, which causes the window to minimize on focus loss.  This means that alt-tab or alt-ctrl-left or alt-ctrl-right will cause the window to minimize.

This means that the opposite operation (e.g. alt-tab again, or alt-ctrl-right or alt-ctrl-left, respectively) which should more or less "undo" the prior corresponding operation, do not undo the prior corresponding operation.  Instead, it sends the window to the bottom of the stack.  So you have to alt-tab a billion times to finally dig down to find your window, idiotically at the bottom of the stack. Only insane people would want this behavior as a default.

An application can counteract this default via:

    setenv("SDL_VIDEO_MINIMIZE_ON_FOCUS", "0", 0);

But this is merely imposing sanity on an insane default.

Why should the default be insane?

A quick google search for "sdl fullscreen alt-tab" will confirm that multitudes have bumped into this, and failed to solve it.
Comment 1 Ryan C. Gordon 2020-04-23 05:01:51 UTC
I genuinely dislike this default setting and have been bitten by it several times, and have wished it would go away in language as strong as Stephen's, but I feel like there was a good reason it was set as such (or at least there _was_ a good reason at one point?)...does anyone remember why?

--ryan.
Comment 2 Byron Roosa 2020-04-28 19:09:43 UTC
I did a little bit of archaeology, and SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS was added in changeset 6755 (in December 2012) along with the SDL_WINDOW_FULLSCREEN_DESKTOP window mode. Before the change, there was a check in place to only minimize a fullscreen window if there was only one display connected, but it appears that the check for a single display was removed in that changeset. In its current state it appears to rely only on SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS.

Here's the output of 'hg log' for that changeset:

changeset:   6755:af77e1a6faf0
user:        Sam Lantinga <slouken@libsdl.org>
date:        Sat Dec 15 00:30:17 2012 +0000
files:       include/SDL_hints.h include/SDL_video.h src/events/SDL_mouse.c src/video/SDL_video.c src/video/cocoa/SDL_cocoawindow.m test/automated/surface/surface.c
description:
Improvements from Alfred:
- Add new SDL_WINDOW_FULLSCREEN_DESKTOP video mode, makes a fullscreen window the size of the desktop (i.e no window manager mode change)
- Fix crash in warp mouse if you specified null as the window
- Added new SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS Hint, if set to 0 then don't minimize a fullscreen window on focus lost (if not set or set to non-zero then minimize on focus loss)

I'm wasn't able to find a direct justification for those changes in the SDL Development mailing lists (at least between 2012 and 2014), but hopefully that might help track down why the changes were made.

Regards,

Byron
Comment 3 Ryan C. Gordon 2020-06-01 19:39:38 UTC
My thinking is that for fullscreen (not fullscreen_desktop) windows, losing focus means you need to put the resolution back to where it normally should be, which is going to cause problems for the now-probably-too-small fullscreen window, not to mention it doesn't have exclusive input focus as it expects...and minimizing was a way to avoid that.

That being said, I'm inclined to change this default and see what breaks, because it fixes a bunch of other headaches to change it.

--ryan.
Comment 4 Ryan C. Gordon 2020-06-27 00:19:25 UTC
(In reply to Ryan C. Gordon from comment #3)
> That being said, I'm inclined to change this default and see what breaks,
> because it fixes a bunch of other headaches to change it.

I've changed the default in https://hg.libsdl.org/SDL/rev/31f7b4b423a2 ...if this causes a bunch of headaches, we'll revert it, but I suspect this will solve a bunch of problems, too.

--ryan.
Comment 5 Dom 2020-06-29 12:46:25 UTC
On Windows this definitely feels like a regression:

1. You can never reach the desktop anymore as there is now no way to minimize the fullscreen window
2. WIN+D now doesn't work anymore
3. If you are in a different display mode (e.g half resolution) due to fullscreen alt+tab now no longer reverts to the old display mode and forces the user to use the other apps with the current (possibly reduced resolution) display mode

I just checked Unreal Engine 4 and their behavior is also like it was before (minimize on focus loss) on Windows and I believe they do not use SDL there.

Btw on Windows the fullscreen window doesn't move to the bottom of the stack after alt-tab so it seems like this issue is specific to Linux as was mentioned in the title of this bug report.