From cef6974c7c0b5ae87b7596446673df5557e5f1f2 Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 4 Aug 2021 11:45:27 +0100 Subject: [PATCH] StandaloneFilterWindow: Fix window resizing bug on Linux On some Linux distros, the audio settings dialog was opening with the wrong size and position. The culprit seems to be the call to setSize() which was called inside resized(). We now try to avoid calling setSize() if we would do so inside a resized() call. --- .../Standalone/juce_StandaloneFilterWindow.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h index 71695c01a8..a011a96a48 100644 --- a/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -283,8 +283,11 @@ public: if (auto* bus = processor->getBus (false, 0)) maxNumOutputs = jmax (0, bus->getDefaultLayout().size()); - o.content.setOwned (new SettingsComponent (*this, deviceManager, maxNumInputs, maxNumOutputs)); - o.content->setSize (500, 550); + auto content = std::make_unique (*this, deviceManager, maxNumInputs, maxNumOutputs); + content->setSize (500, 550); + content->setToRecommendedSize(); + + o.content.setOwned (content.release()); o.dialogTitle = TRANS("Audio/MIDI Settings"); o.dialogBackgroundColour = o.content->getLookAndFeel().findColour (ResizableWindow::backgroundColourId); @@ -542,6 +545,8 @@ private: void resized() override { + const ScopedValueSetter scope (isResizing, true); + auto r = getLocalBounds(); if (owner.getProcessorHasPotentialFeedbackLoop()) @@ -561,9 +566,12 @@ private: void childBoundsChanged (Component* childComp) override { - if (childComp != &deviceSelector) - return; + if (! isResizing && childComp == &deviceSelector) + setToRecommendedSize(); + } + void setToRecommendedSize() + { const auto extraHeight = [&] { if (! owner.getProcessorHasPotentialFeedbackLoop()) @@ -583,6 +591,7 @@ private: AudioDeviceSelectorComponent deviceSelector; Label shouldMuteLabel; ToggleButton shouldMuteButton; + bool isResizing = false; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SettingsComponent)