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 2057 - SDL_SetWindowFullscreen fails when switching between SDL_WINDOW_FULLSCREEN and SDL_WINDOW_FULLSCREEN_DESKTOP
Summary: SDL_SetWindowFullscreen fails when switching between SDL_WINDOW_FULLSCREEN an...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-23 07:01 UTC by Alex Szpakowski
Modified: 2016-03-19 05:03 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Szpakowski 2013-08-23 07:01:21 UTC
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN) will fail (but return 0 for success) if the current state of the window is SDL_WINDOW_FULLSCREEN_DESKTOP.

The reverse is true as well: SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP) will fail (but return success) if the state of the window is currently SDL_WINDOW_FULLSCREEN.

In both cases SDL changes some internal state of the window before it fails to properly set the fullscreen mode, so the window's state gets messed up which causes unexpected things to happen.

The reason this seems to happen is this: SDL_SetWindowFullscreen calls SDL_UpdateFullscreenMode after setting the window's flags to the new fullscreen state, but SDL_UpdateFullscreenMode will early return if fullscreen is requested and the window is already in some type of fullscreen (doesn't matter whether it's normal display-mode or desktop fullscreen.)

So the window's flags get set to the new fullscreen state but the state never actually gets applied.

You can see the problematic early return code here: http://hg.libsdl.org/SDL/file/cf99258f905c/src/video/SDL_video.c#l1091
Comment 1 Sam Lantinga 2013-08-23 07:47:43 UTC
Jorgen, this looks like it's reasonably easy to fix.  Want to take a crack at it?
Comment 2 (disabled) Jørgen Tjernø 2014-01-15 19:20:02 UTC
This should be fixed in http://hg.libsdl.org/SDL/rev/98646f687e2b -- can you look and see if that seems sane, Sam?
Comment 3 Alex Szpakowski 2016-03-19 05:03:16 UTC
This was indeed fixed a while ago.