1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

NSViewComponentPeer: Properly constrain zoomed window size onto current display

This commit is contained in:
reuk 2022-01-06 17:44:28 +00:00
parent 12b7a8f9d1
commit 1edb56df71
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -2353,19 +2353,21 @@ private:
#endif
}
static NSRect windowWillUseStandardFrame (id self, SEL, NSWindow*, NSRect)
static NSRect windowWillUseStandardFrame (id self, SEL, NSWindow*, NSRect r)
{
if (auto* owner = getOwner (self))
{
if (auto* constrainer = owner->getConstrainer())
{
return flippedScreenRect (makeNSRect (owner->getFrameSize().addedTo (owner->getComponent().getScreenBounds()
.withWidth (constrainer->getMaximumWidth())
.withHeight (constrainer->getMaximumHeight()))));
const auto originalBounds = owner->getFrameSize().addedTo (owner->getComponent().getScreenBounds()).toFloat();
const auto expanded = originalBounds.withWidth ((float) constrainer->getMaximumWidth())
.withHeight ((float) constrainer->getMaximumHeight());
const auto constrained = expanded.constrainedWithin (convertToRectFloat (flippedScreenRect (r)));
return flippedScreenRect (makeNSRect (constrained));
}
}
return makeNSRect (Rectangle<int> (10000, 10000));
return r;
}
static BOOL windowShouldZoomToFrame (id self, SEL, NSWindow* window, NSRect frame)