Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSApplicationPresentationHideDock has no effect

I have a window that I want to be able to take fullscreen without allowing access to the dock or the menu bar.

I am enabling fullscreen support by setting the window collection behavior to NSWindowCollectionBehaviorFullScreenPrimary. I have tried setting the collection behavior in both IB and by calling setCollectionBehavior: directly and it has no effect on the issue.

My window delegate also responds to window:willUseFullScreenPresentationOptions: returning the options NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar

The window has the fullscreen button available in the titlebar and moves in and out of fullscreen mode just fine so I know I have setup the fullscreen support correctly.

The menu bar behaves exactly as it is supposed to based on the presentation options I provide.

The dock how ever is a different story, it is always acting as if I passed the auto hide option and will slide into view when I move the mouse to the bottom of the screen no matter what option I provide in window:willUseFullScreenPresentationOptions:

It is really odd as I get a hidden menu bar with an auto hide dock, and if you were to return this equivalent combination of flags (NSApplicationPresentationAutoHideDock | NSApplicationPresentationHideMenuBar) in window:willUseFullScreenPresentationOptions: you get an exception saying that combination is not valid.

Am I missing something?

Update 1:

Tried this on OS X 10.8 and it works just as the docs indicate it should. On OS X 10.9 and OS X 10.10 it fails every time. Also tried Apple's sample code project "FullScreenWindow" it specifies the flags just as I do and it also fails to hide the dock on 10.9 and 10.10, works perfect on 10.8.

I think this may be an Apple bug, either a problem with the feature or, if they deprecated the feature it is a documentation bug since that is not indicated anywhere.

I have logged it with Apple.

Update 2:

Found the solution!

it seems you must not only provide the windows presentation options. But it seems the application has its own presentation options that will override the windows options.

Added this to my window delegate and everything works.

- (void)windowWillEnterFullScreen:(NSNotification*)notification
{
     [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];
}

- (void)windowDidExitFullScreen:(NSNotification*)notification
{
     [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationDefault];

}
like image 563
Brad S Avatar asked Nov 01 '14 22:11

Brad S


1 Answers

Here is the solution.

it seems you must not only provide the windows presentation options. But it seems the application has its own presentation options that will override the windows options.

Added this to my window delegate and everything works.

- (void)windowWillEnterFullScreen:(NSNotification*)notification
{
     [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];
}

- (void)windowDidExitFullScreen:(NSNotification*)notification
{
     [[NSApplication sharedApplication] setPresentationOptions:NSApplicationPresentationDefault];

}
like image 184
Brad S Avatar answered Oct 23 '22 10:10

Brad S