10.7+ Native menu bar Kiosk mode missing presentation options

EDIT: I'm on 10.8.4 targetting 10.8

In juce_mac_NSViewComponentPeer.mm Desktop::setKioskComponent I got it working with the following approach:

   #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7

    if (peer->hasNativeTitleBar()

          && [peer->window respondsToSelector: @selector (toggleFullScreen:)])

    {
        //enableOrDisable when true means we're enabling?  Restrict the menu and dock if desired
        if (enableOrDisable && ! allowMenusAndBars)
            [NSApp setPresentationOptions: NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar];

        //removed the withObject: enableOrDisable bool param..not sure what purpose it served
        [peer->window performSelector: @selector (toggleFullScreen:) withObject: nil];

    }

 

Added NSWindowDelegate windowDidExitFullScreen to reset the options after full screen exited (doesn't work if done at an earlier stage).  This is needed due to using the NSApp setPresentationOptions as opposed to the proper method noted below.

    static void windowDidExitFullScreen(NSNotification * notification) {

        [NSApp setPresentationOptions: NSApplicationPresentationDefault];

    }

 

From what I can tell the recommended way to specify the options is to use the NSWindowDelegate window:willUseFullScreenPresentationOptions: but this didn't seem to have an easy way to access the allowMenusAndBars, it also didn't appear to properly respect the option to hide the dock (although hiding the menu worked the dock would remain in auto hide mode).

 

Thanks - the first bit makes sense, but your windowDidExitFullScreen stuff won't compile as it's written there, so have you actually tried that bit?

That's odd.  Yes I have and I've just double checked and it compiles fine.  I left out adding the selector part to JuceNSWindow class as I wasn't sure I was encoding things exactly right and figured you'd know how to fill that in properly.  But leaving that out doesn't affect the compilation.  The selector is only available in 10.7+ so it could probably use a check with that and the NSApp setPresentationOptions is 10.6 I believe.

This is how added the selector to JuceNSWindowClass:

        addMethod (@selector (windowDidExitFullScreen:),     windowDidExitFullScreen, "v:", @encode(NSNotification*));

And I added the corresponding static method to JuceNSWindowClass just following windowDidEndLiveResize.

My llvm/clang version is the following:

Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
 

I don't see how it could work, because those parameters are wrong.. You'd need to write it like this:

        addMethod (@selector (windowDidExitFullScreen:),      windowDidExitFullScreen,   "v@:@");


    static void windowDidExitFullScreen (id, SEL, NSNotification*)
    {
        [NSApp setPresentationOptions: NSApplicationPresentationDefault];
    }

 

I'm not sure what to say about it.  It works on my machine.  I'm testing it right now.  If I remove the addMethod part the callback is NOT made.  If I put it back in the callback IS made.  Even switching to your addMethod works with the static method as I have it.  I can't explain it..but I'm certainly not claiming that my way is right.  That's why I left that part out...I didn't want to suggest doing it wrong and figured you'd know how to fill in the pieces properly.

Sorry, it's not clear from your post whether you're saying that the code I posted works, or not?

Obviously it won't work if you remove the addMethod call, but the one I posted above is different to your version, and should be correct AFAICT.

Sorry yes the code you posted works and I realize that I should have written the static method to match the others.  This is how I have it now:

    static void windowDidExitFullScreen(id self, SEL, NSNotification*)
    {
        if (NSViewComponentPeer* const owner = getOwner (self))
            owner->windowDidExitFullScreen();
    }

 

After NSViewComponentPeer::liveResizingEnd I've added:

    void windowDidExitFullScreen()
    {
        [NSApp setPresentationOptions: NSApplicationPresentationDefault];
    }

 

Why would you add that extra method in the peer rather than doing it the way I wrote it above?

Because every other callback uses owner to provide the implementation and I thought you'd appreciate the consistency.  Because there's something to be said for implementation logic to be free from platform wiring.  That's my opinion but beyond that I'm fine with whatever you decide to do!

Ok, I see. I just wondered whether there was some other reason that I was missing.

I've committed some changes - give it a go.

Ah yeah no major reason.  I'm currently debugging why isMouseOver seems to sometimes incorrectly return false and I've got a bunch of dbg statements in the JUCE code, but I'll update when I get finished and let you know.  Thanks, much appreciated!

Confirmed in the latest tip.  Thanks!