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 1167

Summary: SDL_WINDOWPOS_CENTERED doesn't work if used right after fullscreen -> windowed switch
Product: SDL Reporter: Vern Jensen <vern>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: x86   
OS: Mac OS X 10.6   

Description Vern Jensen 2011-03-10 16:27:45 UTC
If my program calls SDL_SetWindowFullscreen to exit from fullscreen mode back to windowed mode, the window's position is too low on the screen. I attempted to fix this by adding a call to SDL_SetWindowPosition with SDL_WINDOWPOS_CENTERED used, but that made things far worse... the window would end up almost entirely off the screen, with just the corner of it visible in the lower-right corner of the screen.

I managed to use a hack to get it to work. I found that SDL_SetWindowPosition DOES work if you use an absolute value, like 50, 50. So if I do that *first*, and *then* use SDL_WINDOWPOS_CENTERED, I get a properly centered window:

      // Hack to get around SDL bug, so the SECOND call works!
SDL_SetWindowPosition(gSpriteWorldP->mainWindow, 50, 50); 
SDL_SetWindowPosition(gSpriteWorldP->mainWindow, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);


Version: SDL-1.3.0-5445
Comment 1 Sam Lantinga 2011-03-11 16:55:34 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/6b65ff3cee62

BTW, with the latest code you shouldn't need to put the window back on the screen - it should return to its previous position.