Programmatically exit Kiosk mode (OS X)

JUCE does not seem to have a mechanism to exit kiosk mode if you use the Native Title Bar and enter kiosk mode. Note that this is different than entering Full-screen mode.

Full-screen mode is achieved by holding option and clicking the green ‘maximize’ button. The green button will turn into a (+) when you do that.

I tried this:

            if( window->getPeer()->isKioskMode() )
            {
                DBG( "is kiosk mode" );
//                auto* kiosk = Desktop::getInstance().getKioskModeComponent();
                Desktop::getInstance().setKioskModeComponent(window);
                Desktop::getInstance().setKioskModeComponent(nullptr);

but, when you set it to nullptr, the window's bounds are restored to the kiosk window’s dimensions, because of this line:

        if (kioskModeComponent != nullptr)
        {
            // Only components that are already on the desktop can be put into kiosk mode!
            jassert (ComponentPeer::getPeerFor (kioskModeComponent) != nullptr);

            kioskComponentOriginalBounds = kioskModeComponent->getBounds(); <<<<<<<
            setKioskComponent (kioskModeComponent, true, allowMenusAndBars);
        }

It seems like the toggleFullScreen selector in juce_mac_NSViewComponentPeer.mm is missing some kind of connection to the usual ComponentPeer member functions.

This is the only mention anything related to maximizing in NSViewComponentPeer

//NSViewComponentPeer.mm line 134
            if ((windowStyleFlags & (windowHasMaximiseButton | windowHasTitleBar)) == (windowHasMaximiseButton | windowHasTitleBar))
                [window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];

https://developer.apple.com/documentation/appkit/nswindow/1419527-togglefullscreen?language=objc

Perhaps the solution is to populate the Desktop::kioskModeComponent with the whatever peer is being used when you click that native title bar full-screen button?

3 Likes

Any news on that issue ?