diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index a3375a1b24..29049c17aa 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -811,6 +811,11 @@ private: editorScaleFactor = ec.lastScaleFactorReceived; component.reset (new ContentWrapperComponent (*this, p)); + + #if JUCE_MAC + if (getHostType().type == PluginHostType::SteinbergCubase10) + cubase10Workaround.reset (new Cubase10WindowResizeWorkaround (*this)); + #endif } tresult PLUGIN_API queryInterface (const TUID targetIID, void** obj) override @@ -907,6 +912,11 @@ private: component->setSize (w, h); + #if JUCE_MAC + if (cubase10Workaround != nullptr) + cubase10Workaround->triggerAsyncUpdate(); + else + #endif if (auto* peer = component->getPeer()) peer->updateBounds(); } @@ -1211,6 +1221,23 @@ private: #if JUCE_MAC void* macHostWindow = nullptr; bool isNSView = false; + + // On macOS Cubase 10 resizes the host window after calling onSize() resulting in the peer + // bounds being a step behind the plug-in. Calling updateBounds() asynchronously seems to fix things... + struct Cubase10WindowResizeWorkaround : public AsyncUpdater + { + Cubase10WindowResizeWorkaround (JuceVST3Editor& o) : owner (o) {} + + void handleAsyncUpdate() override + { + if (auto* peer = owner.component->getPeer()) + peer->updateBounds(); + } + + JuceVST3Editor& owner; + }; + + std::unique_ptr cubase10Workaround; #endif float editorScaleFactor = 1.0f;