diff --git a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp index 8ea64e0801..87cf1863e1 100644 --- a/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VST3PluginFormat.cpp @@ -1606,8 +1606,12 @@ private: bool) override { auto rect = componentToVST3Rect (bounds); - view->checkSizeConstraint (&rect); - bounds = vst3ToComponentRect (rect); + auto constrainedRect = rect; + view->checkSizeConstraint (&constrainedRect); + + // Prevent inadvertent window growth while dragging; see componentMovedOrResized below + if (constrainedRect.getWidth() != rect.getWidth() || constrainedRect.getHeight() != rect.getHeight()) + bounds = vst3ToComponentRect (constrainedRect); } //============================================================================== @@ -1633,19 +1637,29 @@ private: if (view->canResize() == kResultTrue) { - auto rect = componentToVST3Rect (getLocalBounds()); - view->checkSizeConstraint (&rect); + // componentToVST3Rect will apply DPI scaling and round to the nearest integer; vst3ToComponentRect + // will invert the DPI scaling, but the logical size returned by vst3ToComponentRect may be + // different from the original size due to floating point rounding if the scale factor is > 100%. + // This can cause the window to unexpectedly grow while it's moving. + auto scaledRect = componentToVST3Rect (getLocalBounds()); + auto constrainedRect = scaledRect; + view->checkSizeConstraint (&constrainedRect); + + const auto tieRect = [] (const auto& x) { return std::tuple (x.getWidth(), x.getHeight()); }; + + // Only update the size if the constrained size is actually different + if (tieRect (constrainedRect) != tieRect (scaledRect)) { - const ScopedValueSetter recursiveResizeSetter (recursiveResize, true); + const ScopedValueSetter recursiveResizeSetter (recursiveResize, true); - const auto logicalSize = vst3ToComponentRect (rect); + const auto logicalSize = vst3ToComponentRect (constrainedRect); setSize (logicalSize.getWidth(), logicalSize.getHeight()); } embeddedComponent.setBounds (getLocalBounds()); - view->onSize (&rect); + view->onSize (&constrainedRect); } else { @@ -1752,6 +1766,12 @@ private: attachedCalled = true; updatePluginScale(); + + #if JUCE_WINDOWS + // Make sure the embedded component window is the right size + // and invalidate the embedded HWND and any child windows + embeddedComponent.updateHWNDBounds(); + #endif } }