From bf486875444909837896ca49f2f45f09eed976b2 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 26 Apr 2016 16:57:22 +0100 Subject: [PATCH] Made the OSX window code handle custom desktop scale factors when constraining window positions --- .../native/juce_mac_NSViewComponentPeer.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 27fdb1cf6d..494958bfd1 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -999,8 +999,10 @@ public: { if (constrainer != nullptr && ! isKioskMode()) { - Rectangle pos (convertToRectInt (flippedScreenRect (r))); - Rectangle original (convertToRectInt (flippedScreenRect ([window frame]))); + const float scale = getComponent().getDesktopScaleFactor(); + + Rectangle pos = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect (r))); + Rectangle original = ScalingHelpers::unscaledScreenPosToScaled (scale, convertToRectInt (flippedScreenRect ([window frame]))); const Rectangle screenBounds (Desktop::getInstance().getDisplays().getTotalBounds (true)); @@ -1023,6 +1025,8 @@ public: pos.getX() == original.getX() && pos.getRight() != original.getRight()); } + pos = ScalingHelpers::scaledScreenPosToUnscaled (scale, pos); + r = flippedScreenRect (makeNSRect (pos)); }