From f77b286b8cd8c1942a4b47c1de8c862e941ebb02 Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 31 Mar 2022 19:29:21 +0100 Subject: [PATCH] VST3 Client: Work around broken editor resizing in Blue Cat's PatchWork --- .../VST3/juce_VST3_Wrapper.cpp | 32 +++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) 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 f06952a4f1..9cd29ecad4 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -642,10 +642,12 @@ class JuceVST3EditController : public Vst::EditController, private ComponentRestarter::Listener { public: - JuceVST3EditController (Vst::IHostApplication* host) + explicit JuceVST3EditController (Vst::IHostApplication* host) { if (host != nullptr) host->queryInterface (FUnknown::iid, (void**) &hostContext); + + blueCatPatchwork |= isBlueCatHost (host); } //============================================================================== @@ -675,6 +677,8 @@ public: if (hostContext != context) hostContext = context; + blueCatPatchwork |= isBlueCatHost (context); + return kResultTrue; } @@ -1284,6 +1288,27 @@ public: static constexpr auto pluginShouldBeMarkedDirtyFlag = 1 << 16; private: + bool isBlueCatHost (FUnknown* context) const + { + // We can't use the normal PluginHostType mechanism here because that will give us the name + // of the host process. However, this plugin instance might be loaded in an instance of + // the BlueCat PatchWork host, which might itself be a plugin. + + VSTComSmartPtr host; + host.loadFrom (context); + + if (host == nullptr) + return false; + + Vst::String128 name; + + if (host->getName (name) != kResultOk) + return false; + + const auto hostName = toString (name); + return hostName.contains ("Blue Cat's VST3 Host"); + } + friend class JuceVST3Component; friend struct Param; @@ -1359,6 +1384,7 @@ private: inSetupProcessing { false }; int lastLatencySamples = 0; + bool blueCatPatchwork = isBlueCatHost (hostContext.get()); #if ! JUCE_MAC float lastScaleFactorReceived = 1.0f; @@ -2065,9 +2091,9 @@ private: auto host = getHostType(); #if JUCE_MAC - if (host.isWavelab() || host.isReaper()) + if (host.isWavelab() || host.isReaper() || owner.owner->blueCatPatchwork) #else - if (host.isWavelab() || host.isAbletonLive() || host.isBitwigStudio()) + if (host.isWavelab() || host.isAbletonLive() || host.isBitwigStudio() || owner.owner->blueCatPatchwork) #endif setBounds (editorBounds.withPosition (0, 0)); }