diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index a9c24afa7a..de2a388023 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -2977,7 +2977,9 @@ public: void nativeScaleFactorChanged (double newScaleFactor) override { setScaleFactorAndDispatchMessage (newScaleFactor); - componentMovedOrResized (true, true); + #if JUCE_WINDOWS + resizeToFit(); + #endif } void setScaleFactorAndDispatchMessage (double newScaleFactor) @@ -3278,40 +3280,33 @@ private: //============================================================================== #if JUCE_WINDOWS - bool willCauseRecursiveResize (int w, int h) - { - auto newScreenBounds = Rectangle (w, h).withPosition (getScreenPosition()); - return Desktop::getInstance().getDisplays().getDisplayForRect (newScreenBounds)->scale != nativeScaleFactor; - } - bool isWindowSizeCorrectForPlugin (int w, int h) { - if (! isShowing() || pluginRefusesToResize) + if (pluginRefusesToResize) return true; return (isWithin (w, getWidth(), 5) && isWithin (h, getHeight(), 5)); } + void resizeToFit() + { + Vst2::ERect* rect = nullptr; + dispatch (Vst2::effEditGetRect, 0, 0, &rect, 0); + + auto w = roundToInt ((rect->right - rect->left) / nativeScaleFactor); + auto h = roundToInt ((rect->bottom - rect->top) / nativeScaleFactor); + + if (! isWindowSizeCorrectForPlugin (w, h)) + { + updateSizeFromEditor (w, h); + sizeCheckCount = 0; + } + } + void checkPluginWindowSize() { if (! pluginRespondsToDPIChanges) - { - Vst2::ERect* rect = nullptr; - dispatch (Vst2::effEditGetRect, 0, 0, &rect, 0); - - auto w = roundToInt ((rect->right - rect->left) / nativeScaleFactor); - auto h = roundToInt ((rect->bottom - rect->top) / nativeScaleFactor); - - if (! isWindowSizeCorrectForPlugin (w, h)) - { - // If plug-in isn't DPI aware then we need to resize our window, but this may cause a recursive resize - // so add a check - if (! willCauseRecursiveResize (w, h)) - updateSizeFromEditor (w, h); - - sizeCheckCount = 0; - } - } + resizeToFit(); } // hooks to get keyboard events from VST windows..