[BUG] 6.1.3 breaks fullscreen (non-native titlebar, macOS Monterey)

Steps to reproduce:

  1. check out 6.1.2, compile Projucer, make a new GUI App
  2. comment out setUsingNativeTitleBar (true);
  3. compile, run and click Maximize button → it maximizes
  4. click Maximize again → it restores the previous size successfully
  5. repeat 1-4. with 6.1.3 → 3. works but 4. doesn’t
  6. repeat 1-4. with 6.1.5 → neither 3. nor 4. work: clicking the Maximize button has no effect.

I’ve noticed this too, when adding the maximise button to the standalone plugin window.

The problem occurs in juce_mac_NSViewComponentPeer.mm:

        if (hasNativeTitleBar())
            if (shouldBeFullScreen != isFullScreen())
                [window toggleFullScreen: nil];
// Does nothing!!!
            [window zoom: nil];

Here’s a workaround for classic maximise behaviour (instead of fullscreen):

// Override maximiseButtonPressed on DocumentWindow class
    void maximiseButtonPressed() override {
        if(!maximised) {
            nonMaximisedBounds = getContentComponent()->getBounds().withPosition(getPosition());
            auto size = Desktop::getInstance().getDisplays().getPrimaryDisplay()->userArea;
            getContentComponent()->setBounds(0, 0, size.getWidth(), size.getHeight());
            setTopLeftPosition(0, 0);
            maximised = true;
        else {
            maximised = false;
// Header of your document window
    bool maximised = false;
    Rectangle<int> nonMaximisedBounds;

Thx @timothyschoen :slight_smile: I had debugged through this line, and was wondering why it had no effect.

Follow up question: I’m curious why can’t we have proper fullscreen when there isn’t a native title bar… is this an OS limitation?

I don’t think so, this should be easy to fix. I think that just removing the if-statement and always do

if (shouldBeFullScreen != isFullScreen())
                [window toggleFullScreen: nil];

It does enter the fullscreen state correctly, but it doesn’t always resize the content component. Another side-effect is that the native titlebar is always available for a fullscreen app on MacOS, so you’ll have two titlebars.

Thanks for reporting.

I’ve updated the behaviour for windows with non-native titlebars so that it matches the behaviour of windows with native titlebars. This means that the maximise button now takes non-native windows into fullscreen mode. This behaviour more closely matches the behaviour on Windows and Linux, where the maximise button always makes the window fill the screen, rather than just zooming to the largest size allowed by the window’s bounds constrainer.

Another nice side-effect of this change is that isFullscreen will return true after calling setFullscreen (true) on a window with a non-native titlebar (this was not the case previously).

1 Like


Thanks @reuk, will test and report back if necessary.

Thanks - but I’m finding the behaviour is now frustrating users.

On most Mac apps the maximise button puts you into fullscreen, but you can opt-click on it to get the old (preferred) behaviour of maximising to available bounds, leaving the menu bar in place.

Can we add that?

As it is currently, we’re getting weird stuff like: tabbing to another app then tabbing back makes the main UI hidden (somewhere).

We can take a look at this, but because it’s platform-specific behaviour it could be quite awkward to fit into the current API. I can’t promise any timeframe for this.

If you can provide repro steps and affected platforms for these issues, I can take a look. Do you see the same problem in the JUCE DemoRunner or other example projects? In general, regressions like this are treated as higher-priority than new functionality.

Take Projucer as the example (with the native title bar)
If you opt-click on the maximise button you get the old behaviour.
An app with non-native title bar doesn’t have that option.
They ought to be consistent right?

Here’s the frustrating behaviour demonstrated with Projucer:
Make it fullscreen
go to the menu and open another window (UTF-8 String converter)
Where did the main UI go?
App-switch using cmd-tab - then App-switch back,
Still no main window and even “show all windows” doesn’t reveal it.

I realise this is partly a side effect of the way the OS handles fullscreen apps, but it’s such a horrible user experience that we absolutely need a way to offer the traditional “maximise” behaviour.

Testing on Monterey FWIW.

Here’s what I ended up doing - override maximiseButtonPressed().
Unfortunately the key modifiers from the button press aren’t passed along.
Maybe ButtonListenerProxy::buttonClicked() needs a ModifierKeys argument.

      void maximiseButtonPressed() override
                if(auto dsply = Desktop::getInstance().getDisplays().getDisplayForPoint( {getX(), getY()}) )
                setFullScreen (! isFullScreen());
1 Like