1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

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.
This commit is contained in:
reuk 2021-08-04 11:45:27 +01:00
parent 61e5f983d9
commit cef6974c7c

View file

@ -283,8 +283,11 @@ public:
if (auto* bus = processor->getBus (false, 0)) if (auto* bus = processor->getBus (false, 0))
maxNumOutputs = jmax (0, bus->getDefaultLayout().size()); maxNumOutputs = jmax (0, bus->getDefaultLayout().size());
o.content.setOwned (new SettingsComponent (*this, deviceManager, maxNumInputs, maxNumOutputs)); auto content = std::make_unique<SettingsComponent> (*this, deviceManager, maxNumInputs, maxNumOutputs);
o.content->setSize (500, 550); content->setSize (500, 550);
content->setToRecommendedSize();
o.content.setOwned (content.release());
o.dialogTitle = TRANS("Audio/MIDI Settings"); o.dialogTitle = TRANS("Audio/MIDI Settings");
o.dialogBackgroundColour = o.content->getLookAndFeel().findColour (ResizableWindow::backgroundColourId); o.dialogBackgroundColour = o.content->getLookAndFeel().findColour (ResizableWindow::backgroundColourId);
@ -542,6 +545,8 @@ private:
void resized() override void resized() override
{ {
const ScopedValueSetter<bool> scope (isResizing, true);
auto r = getLocalBounds(); auto r = getLocalBounds();
if (owner.getProcessorHasPotentialFeedbackLoop()) if (owner.getProcessorHasPotentialFeedbackLoop())
@ -561,9 +566,12 @@ private:
void childBoundsChanged (Component* childComp) override void childBoundsChanged (Component* childComp) override
{ {
if (childComp != &deviceSelector) if (! isResizing && childComp == &deviceSelector)
return; setToRecommendedSize();
}
void setToRecommendedSize()
{
const auto extraHeight = [&] const auto extraHeight = [&]
{ {
if (! owner.getProcessorHasPotentialFeedbackLoop()) if (! owner.getProcessorHasPotentialFeedbackLoop())
@ -583,6 +591,7 @@ private:
AudioDeviceSelectorComponent deviceSelector; AudioDeviceSelectorComponent deviceSelector;
Label shouldMuteLabel; Label shouldMuteLabel;
ToggleButton shouldMuteButton; ToggleButton shouldMuteButton;
bool isResizing = false;
//============================================================================== //==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SettingsComponent) JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SettingsComponent)