ResizableWindow::maximiseButtonPressed() not called?


#1

On Mac, when using a native title bar, the maximise button does not call ResitableWindow::maximiseButtonPressed(). This is JUCE 146 I am using, is there any cure for this problem?


#2

Hey Jules,
I ran into the same issue last night, is there a reason why it doesn’t get called on Mac. I’m using the latest jUCE tip.
Thanks


#3

I guess I never added a callback for that. Will take a look…


#4

Er… just had a look, and it was never actually meant to be called by the maximise button of a native title bar, on any platform. That method is simply a callback from the juce button in a non-native title bar. When the OS resizes the window you get a size change, but it can’t necessarily tell whether it was caused by the maximise button.


#5

well ok… I have a DocumentWindow that has a ComponentBoundsConstrainer set with setConstrainer(), and my maximum size is 800x600.

Then the above doesn’t seem to work. When the maximize button is pressed the os just makes the window full screen, the constraints never get checked. Unless I have to override DocumentWindow resized, let me check…


#6

So how do you detect if a window is maximised or not?bool full = isFullScreen() || (getScreenBounds() == getParentMonitorArea()); is simply never true, even if I use getLocalBounds() or getBounds() for the bounds. If I print the values, I see:

getScreenBounds(): 0 44 1920 1152
getParentMonitorArea(): 0 22 1920 1174

I’d just rather isFullScreen() worked, but it doesn’t seem to do so on the Mac…


#7

It’s a tricky one on OSX, because it doesn’t really have a concept of “maximised”… When you press the green button, it really just resizes the window, it doesn’t put it into a different kind of mode. But you might have more luck if you call ComponentPeer::getFrameSize() and add that to the window’s bounds.


#8

This codebool PersistentWindow::isFullScreen() const { return DocumentWindow::isFullScreen() || (getScreenBounds() == getPeer()->getFrameSize().subtractedFrom( getParentMonitorArea())); }does in fact detect a full screen on the Mac, right the first time Jules!

Perhaps contemplate making the implementation of isFullScreen() on the Mac exactly that code?

So this gets my further to what I want but not quite there. This is such a tiny feature but :smiley: I can be a little obsessive - but this is VERY low on my real priority scale!

My underlying aesthetic is that anything with a state in the program should be persistent and it should stop and restart fast and into exactly the same observable state. If you start off doing this, it ends up as pretty easy to do… except I can’t quite do this with the full window state!

The issue is that I have no way from my program to do exactly the same as “pressing the Mac’s full screen button” - setFullScreen doesn’t have quite the same behaviour.

Here’s what happens. I set up my window so it’s “compact” and then I toggle between “full screen” and “compact” with the Mac’s “full screen” button. Fine! And if I quit while in compact mode and restart, fine!

And if I quit in full screen mode, it should be fine, because my “preferences” show my original “compact” window size, and a flag to say, “Full screen toggle”. So when I restart, my window sets to the stored “compact” size, and then my code calls “setFullScreen” and I should be good…

but in fact, setFullScreen is basically the same as setSize(size of full screen) and doesn’t interact with the “full screen” toggle for the Mac.

There are two ways this could be solved. If I could completely hijack the full screen button, which I haven’t been able to, then I could do it all myself - or if I could really send the equivalent of “press the full screen toggle button”, that’d be even better…


#9

OK, even more weird. If I call setFullScreen programmatically from my code, isFullScreen() always returns true for that window thereafter - even if I have resized the window to be very small!


#10

Ok… I clearly need to take a look at that. Will have a look today…


#11