Fullscreen Windows on OSX Lion

BlitzMax Forums/BlitzMax Module Tweaks/Fullscreen Windows on OSX Lion

JoshK(Posted 2012) [#1]
OS X Lion offers systemwide support for gorgeous, full-screen apps that use every inch of your Mac display. You can have multiple full-screen apps open at once — along with multiple standard-sized apps. And it’s easy to switch between full-screen and desktop views.

It's easy to add fullscreen windows for OSX Lion. First, we need to add a new window style. Open "maxgui.mod/maxgui.mod/gadget.bmx" and add this code at line 68:
Const WINDOW_FULLSCREEN=1024


Now, for the Objective-C side. Open "maxgui.mod/maxgui.mod/maxgui.h" and add this code at line 1761:
#define WINDOW_FULLSCREEN 1024


Open "maxgui.mod/cocoamaxgui.mod/cocoa.macos.m" and add this code at line 1776 (in the WindowView initWithContentRect function). There is a check for OS versions older than Lion, so this should still run on Snow Leopard:
	//OSX Lion full-screen window
	if (gadget->style&WINDOW_FULLSCREEN)
	{
		SInt32 majorVersion, minorVersion;
		Gestalt(gestaltSystemVersionMajor, &majorVersion);
		Gestalt(gestaltSystemVersionMinor, &minorVersion);	
		if (majorVersion > 10 || (majorVersion == 10 && minorVersion >= 7))
		{
			const int NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7;
	    	[self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
		}
	}


To enable full-screen windows, just add the WINDOW_FULLSCREEN style when the window is created. Here's an example program:


That's it! You can now enable full-screen windows in OSX Lion.


shinkiro1(Posted 2012) [#2]
Wow! How cool is that. You are a hero!!
Fullscreen is absolutely great. Worked perfectly.
Thank you very much.

Just a note:
Now, for the Objective-C side. Open "maxgui.mod/maxgui.mod/maxgui.h" and add this code at line 1761:

Maybe you meant 'code at line 176'

Last edited 2012


AdamStrange(Posted 2012) [#3]
heres a question - How would I force an app to go into fullscreen?

I have the menu entries and all that code, I just need the code to trigger the app going into fullscreen ?