Browse Source

DocumentWindow: Made macOS windows respect constrainer minSize when in split screen

tags/2021-05-28
reuk Tom Poole 5 years ago
parent
commit
f9532f609e
1 changed files with 33 additions and 27 deletions
  1. +33
    -27
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm

+ 33
- 27
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -1074,11 +1074,13 @@ public:
void liveResizingStart()
{
if (constrainer != nullptr)
{
constrainer->resizeStart();
isFirstLiveResize = true;
}
if (constrainer == nullptr)
return;
constrainer->resizeStart();
isFirstLiveResize = true;
setFullScreenSizeConstraints (*constrainer);
}
void liveResizingEnd()
@@ -1087,37 +1089,34 @@ public:
constrainer->resizeEnd();
}
NSRect constrainRect (NSRect r)
NSRect constrainRect (const NSRect r)
{
if (constrainer != nullptr && ! isKioskMode())
{
auto scale = getComponent().getDesktopScaleFactor();
if (constrainer == nullptr || isKioskMode())
return r;
auto pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r)));
auto original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame])));
const auto scale = getComponent().getDesktopScaleFactor();
auto screenBounds = Desktop::getInstance().getDisplays().getTotalBounds (true);
auto pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r)));
const auto original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame])));
const bool inLiveResize = [window inLiveResize];
const auto screenBounds = Desktop::getInstance().getDisplays().getTotalBounds (true);
if (! inLiveResize || isFirstLiveResize)
{
isFirstLiveResize = false;
const bool inLiveResize = [window inLiveResize];
isStretchingTop = (pos.getY() != original.getY() && pos.getBottom() == original.getBottom());
isStretchingLeft = (pos.getX() != original.getX() && pos.getRight() == original.getRight());
isStretchingBottom = (pos.getY() == original.getY() && pos.getBottom() != original.getBottom());
isStretchingRight = (pos.getX() == original.getX() && pos.getRight() != original.getRight());
}
constrainer->checkBounds (pos, original, screenBounds,
isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight);
if (! inLiveResize || isFirstLiveResize)
{
isFirstLiveResize = false;
pos = ScalingHelpers::scaledScreenPosToUnscaled (scale, pos);
r = flippedScreenRect (makeNSRect (pos));
isStretchingTop = (pos.getY() != original.getY() && pos.getBottom() == original.getBottom());
isStretchingLeft = (pos.getX() != original.getX() && pos.getRight() == original.getRight());
isStretchingBottom = (pos.getY() == original.getY() && pos.getBottom() != original.getBottom());
isStretchingRight = (pos.getX() == original.getX() && pos.getRight() != original.getRight());
}
return r;
constrainer->checkBounds (pos, original, screenBounds,
isStretchingTop, isStretchingLeft, isStretchingBottom, isStretchingRight);
return flippedScreenRect (makeNSRect (ScalingHelpers::scaledScreenPosToUnscaled (scale, pos)));
}
static void showArrowCursorIfNeeded()
@@ -1563,6 +1562,13 @@ private:
return true;
}
void setFullScreenSizeConstraints (const ComponentBoundsConstrainer& c)
{
const auto minSize = NSMakeSize (static_cast<float> (c.getMinimumWidth()),
0.0f);
[window setMinFullScreenContentSize: minSize];
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NSViewComponentPeer)
};


Loading…
Cancel
Save