From 655a6e93678e9ee6f8f6cd871a2a7ce6aebade05 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 5 Mar 2021 18:04:02 +0000 Subject: [PATCH] VST: Use ComponentPeer::getAreaCoveredBy() to get scaled editor bounds on Windows and Linux --- .../format_types/juce_VSTPluginFormat.cpp | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index bcc1e3d884..647a6b55be 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -2851,38 +2851,30 @@ public: if (recursiveResize) return; - auto* topComp = getTopLevelComponent(); - - if (topComp->getPeer() != nullptr) + if (auto* peer = getTopLevelComponent()->getPeer()) { - auto pos = (topComp->getLocalPoint (this, Point()) * nativeScaleFactor).roundToInt(); + const ScopedValueSetter recursiveResizeSetter (recursiveResize, true); - recursiveResize = true; + auto pos = (peer->getAreaCoveredBy (*this).toFloat() * nativeScaleFactor).toNearestInt(); #if JUCE_WINDOWS if (pluginHWND != 0) { ScopedThreadDPIAwarenessSetter threadDpiAwarenessSetter { pluginHWND }; - - MoveWindow (pluginHWND, pos.getX(), pos.getY(), - roundToInt (getWidth() * nativeScaleFactor), - roundToInt (getHeight() * nativeScaleFactor), - TRUE); + MoveWindow (pluginHWND, pos.getX(), pos.getY(), pos.getWidth(), pos.getHeight(), TRUE); } #elif JUCE_LINUX if (pluginWindow != 0) { X11Symbols::getInstance()->xMoveResizeWindow (display, pluginWindow, pos.getX(), pos.getY(), - static_cast (roundToInt ((float) getWidth() * nativeScaleFactor)), - static_cast (roundToInt ((float) getHeight() * nativeScaleFactor))); + (unsigned int) pos.getWidth(), + (unsigned int) pos.getHeight()); X11Symbols::getInstance()->xMapRaised (display, pluginWindow); X11Symbols::getInstance()->xFlush (display); } #endif - - recursiveResize = false; } }