From 954663b8bb36cdc3f62f2211a8749a8d4db29317 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 18 Dec 2018 17:15:23 +0000 Subject: [PATCH] VST3: Added a workaround for Cubase 10 resizing the host window after the plug-in on macOS --- .../VST3/juce_VST3_Wrapper.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) 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;