Sam Lantinga bcf5472d16 Fixed bug 2073 - Mac: window moves unexpectedly when exiting SDL_WINDOW_FULLSCREEN_DESKTOP mode
Alex Szpakowski

In Mac OS X, when SDL_SetWindowFullscreen(window, 0) is called on a window which was in SDL_WINDOW_FULLSCREEN_DESKTOP mode, its original size is restored but its position is moved to the bottom of the screen.

I tracked down the issue to these two lines: http://hg.libsdl.org/SDL/file/fdd5cc9e9f90/src/video/cocoa/SDL_cocoawindow.m#l1034

I believe [nswindow setFrameOrigin:rect.origin] implicitly calls [nswindow constrainFrameRect:rect toScreen:screen], which will attempt to constrain the window to the screen, but at that point the window size is still full-screen rather than the restored window size, so the constrainFrameRect function operates on the wrong window size.

https://developer.apple.com/library/mac/documentation/cocoa/reference/applicationkit/classes/NSWindow_Class/Reference/Reference.html#//apple_ref/occ/instm/NSWindow/constrainFrameRect:toScreen:

I resolved the issue by swapping the order of the function calls, like so:
[nswindow setContentSize:rect.size];
[nswindow setFrameOrigin:rect.origin];
2013-10-21 02:37:03 -07:00
2013-10-17 23:02:29 -07:00
2013-10-20 20:49:36 -07:00



                         Simple DirectMedia Layer



                                  (SDL)



                                Version 2.0



---

http://www.libsdl.org/



Simple DirectMedia Layer is a cross-platform development library designed

to provide low level access to audio, keyboard, mouse, joystick, and graphics

hardware via OpenGL and Direct3D. It is used by video playback software,

emulators, and popular games including Valve's award winning catalog

and many Humble Bundle games.



SDL officially supports Windows, Mac OS X, Linux, iOS, and Android.

Support for other platforms may be found in the source code.



SDL is written in C, works natively with C++, and there are bindings 

available for several other languages, including C# and Python.



This library is distributed under the zlib license, which can be found

in the file "COPYING.txt".



The best way to learn how to use SDL is to check out the header files in

the "include" subdirectory and the programs in the "test" subdirectory.

The header files and test programs are well commented and always up to date.

More documentation and FAQs are available online at:

	http://wiki.libsdl.org/



If you need help with the library, or just want to discuss SDL related

issues, you can join the developers mailing list:

	http://www.libsdl.org/mailing-list.php



Enjoy!

	Sam Lantinga				(slouken@libsdl.org)



S
Description
Simple Directmedia Layer
Readme
267 MiB
Languages
C 87.5%
C++ 4.4%
Objective-C 3.4%
CMake 1.7%
Python 0.7%
Other 2%