From 4eecccfd92c7eaf72b4fd5f4d189f36986265891 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 30 Mar 2015 12:46:38 +0100 Subject: [PATCH] Fix for Ableton plugin window resizing issues. --- .../VST/juce_VST_Wrapper.cpp | 49 ++++++++++++------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp index fed35c9365..154a118dc5 100644 --- a/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp @@ -256,6 +256,7 @@ public: isProcessing (false), isBypassed (false), hasShutdown (false), + isInSizeWindow (false), firstProcessCallback (true), shouldDeleteEditor (false), #if JUCE_64BIT @@ -1245,7 +1246,16 @@ public: { if (editorComp != nullptr) { - if (! (canHostDo (const_cast ("sizeWindow")) && sizeWindow (newWidth, newHeight))) + bool sizeWasSuccessful = false; + + if (canHostDo (const_cast ("sizeWindow"))) + { + isInSizeWindow = true; + sizeWasSuccessful = sizeWindow (newWidth, newHeight); + isInSizeWindow = false; + } + + if (! sizeWasSuccessful) { // some hosts don't support the sizeWindow call, so do it manually.. #if JUCE_MAC @@ -1375,27 +1385,30 @@ public: void childBoundsChanged (Component* child) override { - child->setTopLeftPosition (0, 0); + if (! wrapper.isInSizeWindow) + { + child->setTopLeftPosition (0, 0); - const int cw = child->getWidth(); - const int ch = child->getHeight(); + const int cw = child->getWidth(); + const int ch = child->getHeight(); - #if JUCE_MAC - if (wrapper.useNSView) - setTopLeftPosition (0, getHeight() - ch); - #endif + #if JUCE_MAC + if (wrapper.useNSView) + setTopLeftPosition (0, getHeight() - ch); + #endif - wrapper.resizeHostWindow (cw, ch); + wrapper.resizeHostWindow (cw, ch); - #if ! JUCE_LINUX // setSize() on linux causes renoise and energyxt to fail. - setSize (cw, ch); - #else - XResizeWindow (display, (Window) getWindowHandle(), cw, ch); - #endif + #if ! JUCE_LINUX // setSize() on linux causes renoise and energyxt to fail. + setSize (cw, ch); + #else + XResizeWindow (display, (Window) getWindowHandle(), cw, ch); + #endif - #if JUCE_MAC - wrapper.resizeHostWindow (cw, ch); // (doing this a second time seems to be necessary in tracktion) - #endif + #if JUCE_MAC + wrapper.resizeHostWindow (cw, ch); // (doing this a second time seems to be necessary in tracktion) + #endif + } } void handleAsyncUpdate() override @@ -1442,7 +1455,7 @@ private: VSTMidiEventList outgoingEvents; VstSpeakerArrangementType speakerIn, speakerOut; int numInChans, numOutChans; - bool isProcessing, isBypassed, hasShutdown, firstProcessCallback; + bool isProcessing, isBypassed, hasShutdown, isInSizeWindow, firstProcessCallback; bool shouldDeleteEditor, useNSView; HeapBlock channels; Array tempChannels; // see note in processReplacing()