The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Can't go to window mode from full screen [Mac] (>=SDL 2.0
^DJ_Link^


Joined: 10 Jun 2011
Posts: 28
Hi everyone.
So I have a bit of a problem that I can't really fix. Maybe something changed that I'm not aware. I have a game built with SDL 2.0.1
I was always able to toggle between fullscreen and window mode, even set different resolutions, no problems there.

I decided to update SDL to 2.0.3 but now, after going to fullscreen the first time, the going to window mode does not work anymore, it only changes the resolution, but the fullscreen stays the same, SDL_SetWindowFullscreen() returns no errors . I did a few tests and it doesn't happen with SDL 2.0.1, but it happens with 2.0.2, 2.0.3 and the newer 2.0.4 RC

My code (that works with 2.0.1) is something like. Any help would be really appreciated.

Code:


bool createWindow(const int width, const int height, bool fullscreen)
{
//check if window was already created
if (_window!=NULL)
   {
            SDL_SetWindowSize(_window, width, height);
         
            if (fullscreen) {
                SDL_SetWindowFullscreen(_window, SDL_WINDOW_FULLSCREEN);
            }
   else{
               SDL_SetWindowFullscreen(_window, SDL_WINDOW_FULLSCREEN);
      SDL_SetWindowPosition(_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
   }
        }
       //Window was never created
        else
        {
            unsigned int flags = SDL_WINDOW_OPENGL;
            if (fullscreen) {
                flags |=SDL_WINDOW_FULLSCREEN;
            }
           
            _window = SDL_CreateWindow(title.c_str(),
                                       SDL_WINDOWPOS_CENTERED,
                                       SDL_WINDOWPOS_CENTERED,
                                       width, height,
                                       flags);
       
            // Create an OpenGL context associated with the window.
            _glcontext = SDL_GL_CreateContext(_window);
         //Call VSync again to our new GL Context
         SDL_GL_SetSwapInterval(1);
        }
^DJ_Link^


Joined: 10 Jun 2011
Posts: 28
Forgot to mention. I'm using Mac OS X Yosemite (10.10.3)
^DJ_Link^


Joined: 10 Jun 2011
Posts: 28
did some poorly copy paste from the code.

this is the correct code I have

Code:


 if (fullscreen) {
                SDL_SetWindowFullscreen(_window, SDL_WINDOW_FULLSCREEN);
            }
   else{
               SDL_SetWindowFullscreen(_window, 0);
      SDL_SetWindowPosition(_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
   }

Can't go to window mode from full screen [Mac] (>=SDL 2.0
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
I just tried this with testsprite2, by using Ctrl-Return to toggle fullscreen mode. I noticed that the window decorations went away when I came back from fullscreen mode, but it toggled just fine here on 10.10.3

On Sun, Jun 28, 2015 at 7:47 AM, ^DJ_Link^ wrote:
Quote:
did some poorly copy paste from the code.

this is the correct code I have




Code:



 if (fullscreen) {
                SDL_SetWindowFullscreen(_window, SDL_WINDOW_FULLSCREEN);
            }
   else{
               SDL_SetWindowFullscreen(_window, 0);
      SDL_SetWindowPosition(_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
   }








@DJ_Link

www.david-amador.com


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Can't go to window mode from full screen [Mac] (>=SDL 2.0
eric.w


Joined: 12 Feb 2014
Posts: 38
On Mon, Jun 29, 2015 at 11:18 PM, Sam Lantinga wrote:
Quote:
I just tried this with testsprite2, by using Ctrl-Return to toggle fullscreen mode. I noticed that the window decorations went away when I came back from fullscreen mode, but it toggled just fine here on 10.10.3




regarding: window decorations disappearing, I get the same thing, Sam. (also on 10.10.3)



If I launch testgl2 with "--resize", then the close/minimuze/fullscreen buttons reappear as soon as I resize the window.
I think this is related: http://stackoverflow.com/questions/27560296/titleclose-button-not-show
and indeed, this adding hacky workaround seems to fix the problem for me:


NSRect r = [nswindow frame];
[nswindow setFrame:NSMakeRect(r.origin.x, r.origin.y, r.size.width + 1, r.size.height) display:NO];
[nswindow setFrame:r display:YES];



after this line in Cocoa_SetWindowFullscreen: 
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];






DJ_Link, I also couldn't reproduce the bug. Could you make a small standalone test app that shows the issue? I'm wondering if some specifics like the initial window size matter. Also, what screen resolution are you seeing this on, and is it a retina screen?


Eric
Re: Can't go to window mode from full screen [Mac] (>=SDL
^DJ_Link^


Joined: 10 Jun 2011
Posts: 28
eric.w wrote:

DJ_Link, I also couldn't reproduce the bug. Could you make a small standalone test app that shows the issue? I'm wondering if some specifics like the initial window size matter. Also, what screen resolution are you seeing this on, and is it a retina screen?

Eric


Ah, weirdly, and I decided to build SDL from source (last commit), and the problem goes away.
For sanity check I compiled the revision 8627 (release-2.0.3) and with that one I have the issue. But it wasn't present in 2.0.1. So between that commit and the latest one it was fixed I think.
I can switch between full screen and window using both SDL_WINDOW_FULLSCREEN and SDL_WINDOW_FULLSCREEN_DESKTOP now. Thank you for the help, I should have tried to build it from source in the first place.

btw, I noticed that on the last commit the Mac project only has Standard Arch (64) instead of Universal. Will that be a thing from now on? I changed the flag for my own build. I know it's weird, but but I have older libs that I can't get to work on 64 builds.
Can't go to window mode from full screen [Mac] (>=SDL 2.0
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Fixed, thanks!

On Tue, Jun 30, 2015 at 12:54 AM, Eric Wasylishen wrote:
Quote:
On Mon, Jun 29, 2015 at 11:18 PM, Sam Lantinga wrote:
Quote:
I just tried this with testsprite2, by using Ctrl-Return to toggle fullscreen mode. I noticed that the window decorations went away when I came back from fullscreen mode, but it toggled just fine here on 10.10.3




regarding: window decorations disappearing, I get the same thing, Sam. (also on 10.10.3)



If I launch testgl2 with "--resize", then the close/minimuze/fullscreen buttons reappear as soon as I resize the window.
I think this is related: http://stackoverflow.com/questions/27560296/titleclose-button-not-show
and indeed, this adding hacky workaround seems to fix the problem for me:


NSRect r = [nswindow frame];
[nswindow setFrame:NSMakeRect(r.origin.x, r.origin.y, r.size.width + 1, r.size.height) display:NO];
[nswindow setFrame:r display:YES];



after this line in Cocoa_SetWindowFullscreen: 
[nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];






DJ_Link, I also couldn't reproduce the bug. Could you make a small standalone test app that shows the issue? I'm wondering if some specifics like the initial window size matter. Also, what screen resolution are you seeing this on, and is it a retina screen?


Eric




_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org