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 3315

Summary: Exiting fullscreen on Windows can cause resizing of other windows
Product: SDL Reporter: Simon Hug <chli.hug>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72, philipp.wiesemann
Version: HG 1.2   
Hardware: All   
OS: Windows (All)   
Attachments: Diff for a fix.
Fixes the mode change in SDL2.

Description Simon Hug 2016-05-02 18:24:23 UTC
Created attachment 2436 [details]
Diff for a fix.

When SDL exits fullscreen on Windows, the mode change is not marked as temporary. This causes windows resized and icons on the desktop moved if it exists from a small resolution.

To fix this, the call to ChangeDisplaySettings should mark the change as temporary.
Comment 1 Simon Hug 2016-05-05 06:01:31 UTC
Created attachment 2442 [details]
Fixes the mode change in SDL2.

I thought only SDL 1.2 is affected, but SDL 2 is doing the same thing. Here's a patch for SDL 2.
Comment 2 Alex Szpakowski 2016-05-23 18:30:16 UTC
Applied via https://hg.libsdl.org/SDL/rev/e49caa693be5 and https://hg.libsdl.org/SDL/rev/7cbfd97f1430 , thanks!
Comment 3 Philipp Wiesemann 2016-05-23 21:01:31 UTC
The applied patch for SDL 2.0 [1] partially reverted an earlier fix for switching from fullscreen to window. [2] It looks like this would handle the case where the resolution is the same.

However, I do not know if the earlier problem still exists or which is more important now. :)

[1] https://hg.libsdl.org/SDL/rev/7cbfd97f1430
[2] https://hg.libsdl.org/SDL/rev/513d97ffe10d
Comment 4 Alex Szpakowski 2016-05-23 21:25:44 UTC
I do remember that earlier problem before it was fixed, but I can't reproduce it now even after the latest commits. Can anyone else?
Comment 5 Philipp Wiesemann 2016-05-26 19:42:37 UTC
I do not get the black screen even if I remove the older fix. So either the black screen is currently prevented from elsewhere or I did something wrong. :)

Also, I get no resized windows with and without the newer fix (for SDL 2.0). SDL_WINDOW_FULLSCREEN was used (not SDL_WINDOW_FULLSCREEN_DESKTOP).
Comment 6 Simon Hug 2016-05-27 06:12:07 UTC
Yeah, I don't get any of these mode changes on exit when removing the newer lines in tip. And there's no actual call to WIN_SetDisplayMode on exiting when testing the parent of [1] so I'm wondering where that comes from. Well, seems fixed now, right?

Now, other windows moving or resizing when exiting fullscreen is a bit harder to reproduce, I guess. I'm currently testing on Windows 8.1 and the CDS_FULLSCREEN flag definitely did help, although in my case the windows are not resizing but just moving to the lower-right corner if I leave out the flag.

Google Chrome is behaving a bit weird though. It seems this program always wants to fit somehow and resizes itself. (Do they watch for mode changes?)

[1] https://hg.libsdl.org/SDL/rev/513d97ffe10d