Problems with kiosk mode


#1

I’m having some issues with kiosk mode both in the JuceDemo and in my own project using Lion with native title bar. I’m using the tip.

Whenever I switch to kiosk mode it always leaves a gap at the top of my screen where the menu bar should show up. I’m guessing this is happening because the native title bar is staying there.

I’m now using obj c calls to setStyleMask and setFrame on my NSWindow instead of using setKioskModeComponent to see if I can isolate the problem. I’ve found that if I set my NSViewComponent size to the size of my screen (i.e. 1920 x 1080) the title bar won’t go away when calling setStyleMask. If I set it to anything other than that (bigger or smaller) then it works perfectly.

Could it be something I’m doing wrong that’s causing this?

Sean


#2

I’ve just updated this to use the new Lion full screen mode - grab the latest version and try again…


#3

Kiosk Mode is working well in Lion 10.7.
Kiosk Mode can work better on Snow Leopard 10.6 with some small modifications.

Currently in 10.6, if you have the native title bar showing and you enter kiosk mode, the native title bar still shows up when fullscreen and the window is actually cut off at the bottom.
With two minor additions to juce_mac_NSViewComponentPeer.mm, we can make sure the native title bar is hidden and the window is displayed properly in fullscreen on 10.6.

Addition #1 (when we are entering fullscreen on 10.6):

if (peer->hasNativeTitleBar()) [peer->window setStyleMask:NSBorderlessWindowMask];

Addition #2 (when we are exiting fullscreen on 10.6):

if (peer->hasNativeTitleBar())
{    
            [peer->window setStyleMask:(NSViewComponentPeer::getNSWindowStyleMask (peer->getStyleFlags()))];
            peer->setTitle (peer->component->getName());
}

I know the setTitle call is a bit odd, but without it, the title of the native title bar is blank when you come out of fullscreen.

Full code:

void Desktop::setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars)
{
   #if defined (MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6

   #if defined (MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
    NSViewComponentPeer* peer = dynamic_cast<NSViewComponentPeer*> (kioskModeComponent->getPeer());

    if (peer != nullptr
         && peer->hasNativeTitleBar()
         && [peer->window respondsToSelector: @selector (toggleFullScreen:)])
    {
        [peer->window performSelector: @selector (toggleFullScreen:)
                           withObject: [NSNumber numberWithBool: (BOOL) enableOrDisable]];
    }
    else
   #endif
    {
        if (enableOrDisable)
        {
            if (peer->hasNativeTitleBar()) [peer->window setStyleMask:NSBorderlessWindowMask];
            [NSApp setPresentationOptions: (allowMenusAndBars ? (NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)
                                                              : (NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar))];
            kioskModeComponent->setBounds (Desktop::getInstance().getMainMonitorArea (false));
        }
        else
        {
            if (peer->hasNativeTitleBar())
            {
                
                [peer->window setStyleMask:(NSViewComponentPeer::getNSWindowStyleMask (peer->getStyleFlags()))];
                peer->setTitle (peer->component->getName());
            }
            [NSApp setPresentationOptions: NSApplicationPresentationDefault];
        }
    }
   #elif JUCE_SUPPORT_CARBON
    if (enableOrDisable)
    {
        SetSystemUIMode (kUIModeAllSuppressed, allowMenusAndBars ? kUIOptionAutoShowMenuBar : 0);
        kioskModeComponent->setBounds (Desktop::getInstance().getMainMonitorArea (false));
    }
    else
    {
        SetSystemUIMode (kUIModeNormal, 0);
    }
   #else
    // If you're targeting OSes earlier than 10.6 and want to use this feature,
    // you'll need to enable JUCE_SUPPORT_CARBON.
    jassertfalse;
   #endif
}

#4

Cool, much appreciated!


#5

i get this error know, because peer definition is inside the #if statements

juceQuake/juce/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm:1800: error: ‘peer’ was not declared in this scope
juceQuake/juce/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm:1809: error: ‘peer’ was not declared in this scope


#6

Oops! Sorry, will fix that!