# Mac and Linux Fullscreen issues

**URL:** <https://discourse.libsdl.org/t/mac-and-linux-fullscreen-issues/18055>\
**Category:** SDL Development\
**Created:** [March 14, 2011, 8:56pm UTC](https://discourse.libsdl.org/t/mac-and-linux-fullscreen-issues/18055 "2011-03-14T20:56:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mako\_energy](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@Mako\_energy](https://discourse.libsdl.org/u/Mako_energy)\
**Post date:** [March 14, 2011, 8:56pm UTC](https://discourse.libsdl.org/t/mac-and-linux-fullscreen-issues/18055/1 "2011-03-14T20:56:20Z")

</div>

I feel kinda bad posting so much about my issues. =\ But here goes…

I finally got windows resizing and fullscreen toggling in Windows working fine, so I started turning my attention to the linux and mac builds. When switching to fullscreen mode in linux, it works initially, but when switching back to windowed mode it seems that it changed the desktop settings, which then have to be reset. Other then that linux seems to work fine. In mac the issue is much worse, causing artifacting issues and ultimately had to be rebooted. I can’t get much more descriptive about the mac issue at this moment because I didn’t see the test personally. I’ll give a better description of the issue in an edit soon though.

Like my previous issues, I’m sure this is something to do with my configuration or setup…probably even something basic. My fullscreen switching code looks like this:

Code:  
if(SDL\_SetWindowFullscreen(SDLwindow, Fullscreen?SDL\_TRUE:SDL\_FALSE ) == 0)  
{  
OgreGameWindow-\>setFullscreen(Fullscreen,Settings.RenderWidth,Settings.RenderHeight);  
CorrectViewportAndCamera();  
Settings.Fullscreen = Fullscreen;  
}

The viewport and camera function just resets the extents of the ogre viewport to be the size of the entire window, and then sets the camera to it’s new aspect ratio based on the updated dimensions. So just ogre stuff.

I tried looking around in the tests and didn’t see anything that used the new code( Such as the SDL\_SetWindowFullscreen() function), so I snooped around in the SDL\_compat.c file to see if anything special was there, and I did find the SDL\_WM\_ToggleFullScreen() function. I recognized the part where it did the switch readily…but the rest I’m not sure what to think of. Am I supposed to be doing these checks in my code as well to get fullscreen toggling to work?

Is there any other code snippets anyone can share to enlighten me as to how this code should be structured or what is going wrong?

---

<div class="post-metadata">

**Author:** ![john\_skaller](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@john\_skaller](https://discourse.libsdl.org/u/john_skaller)\
**Post date:** [March 15, 2011, 9:48am UTC](https://discourse.libsdl.org/t/mac-and-linux-fullscreen-issues/18055/2 "2011-03-15T09:48:24Z")

</div>

> Code:  
> if(SDL\_SetWindowFullscreen(SDLwindow, Fullscreen?SDL\_TRUE:SDL\_FALSE ) == 0)  
> {  
> OgreGameWindow-\>setFullscreen(Fullscreen,Settings.RenderWidth,Settings.RenderHeight);  
> CorrectViewportAndCamera();  
> Settings.Fullscreen = Fullscreen;  
> }

Well that’s interesting … OSX Snow Leopard, using F1 key to switch from  
legacy mode window to full screen and back:

~/felix\>flx --test=build/release/ --force demos/sdl/sdl-1.01.03-0  
Binding libary std  
binding library std done  
Exports = 0  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
~/felix\>flx --test=build/release/ --force demos/sdl/sdl-1.01.03-0  
frames in seconds = FPS  
Tue Mar 15 20:42:24 pa114-73-117-179.pa.nsw.optusnet.com.au flx\_arun[286] : kCGErrorIllegalArgument: CGSShapeWindow  
Tue Mar 15 20:42:24 pa114-73-117-179.pa.nsw.optusnet.com.au flx\_arun[286] : kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.  
Tue Mar 15 20:42:28 pa114-73-117-179.pa.nsw.optusnet.com.au flx\_arun[286] : kCGErrorIllegalArgument: CGSShapeWindow  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS  
frames in seconds = FPS

The missing frame rate is an unknown “other” bug when using dynamic linkage.

Here’s the switching code (written in Felix, translation to C obvious):

```
  {
    block_sdl_events event_lock;
    ignore$ SDL_WM_ToggleFullScreen( surface );
    unblock_sdl_events event_lock;
  }On 15/03/2011, at 7:56 AM, Mako_energy wrote:

```

–  
john skaller  
@john_skaller

---

<div class="post-metadata">

**Author:** ![Mako\_energy](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@Mako\_energy](https://discourse.libsdl.org/u/Mako_energy)\
**Post date:** [March 15, 2011, 4:30pm UTC](https://discourse.libsdl.org/t/mac-and-linux-fullscreen-issues/18055/3 "2011-03-15T16:30:19Z")

</div>

john skaller wrote:

> {  
> block\_sdl\_events event\_lock;  
> ignore$ SDL\_WM\_ToggleFullScreen( surface );  
> unblock\_sdl\_events event\_lock;  
> }

Thanks for sharing, but unfortunately calling that function had zero effect when used instead of SDL\_SetWindowFullscreen(). After debugging the cause seems to be that SDL\_PublicSurface in SDL\_compat.c was never set, because we never called SDL\_SetVideoMode(). We’ve actually removed all the SDL 1.2 specific code from our engine, upgrading to SDL 1.3 so we have no need for the compatibility layer, and it was my understanding that in SDL 1.3 we also don’t need to set the video mode.

---

<div class="post-metadata">

**Author:** ![john\_skaller](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@john\_skaller](https://discourse.libsdl.org/u/john_skaller)\
**Post date:** [March 16, 2011, 9:06am UTC](https://discourse.libsdl.org/t/mac-and-linux-fullscreen-issues/18055/4 "2011-03-16T09:06:09Z")

</div>

> john skaller wrote:
> 
> {  
> block\_sdl\_events event\_lock;  
> ignore$ SDL\_WM\_ToggleFullScreen( surface );  
> unblock\_sdl\_events event\_lock;  
> }
> 
> Thanks for sharing, but unfortunately calling that function had zero effect when used instead of SDL\_SetWindowFullscreen().

because it doesn’t specify the window?

> After debugging the cause seems to be that SDL\_PublicSurface in SDL\_compat.c was never set, because we never called SDL\_SetVideoMode(). We’ve actually removed all the SDL 1.2 specific code from our engine, upgrading to SDL 1.3 so we have no need for the compatibility layer, and it was my understanding that in SDL 1.3 we also don’t need to set the video mode.

I plan to upgrade too, but these are old demos run using the compat layer of Hg version of SDL 1.3.On 16/03/2011, at 3:30 AM, Mako\_energy wrote:

–  
john skaller  
@john_skaller

---

<div class="post-metadata">

**Author:** ![Mako\_energy](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/m/cab0a1/32.png) [@Mako\_energy](https://discourse.libsdl.org/u/Mako_energy)\
**Post date:** [March 16, 2011, 7:07pm UTC](https://discourse.libsdl.org/t/mac-and-linux-fullscreen-issues/18055/5 "2011-03-16T19:07:14Z")

</div>

john skaller wrote:

> because it doesn’t specify the window?

I actually used a function to get the window surface by window pointer, and passed it in that way. So I was specifying the window the only way that was clear to me. I also took a second look at the function and it seems that SDL\_WM\_ToggleFullscreen completely ignores the surface you pass in anyway. Just in no way works with an otherwise entirely 1.3 API.

I did have a little bit of success with my issues on linux though. It seems it stops applying the fullscreen settings to the desktop when I create a SDL\_DisplayMode ahead of time with the parameters I want for the fullscreen window, set it, and then switch to fullscreen. Prior to that I was just letting SDL figure it out.
