@@ -502,7 +502,10 @@ class PlugDataWindow final : public DocumentWindow
502502
503503 bool isMaximised () const
504504 {
505- #if JUCE_LINUX
505+ #if JUCE_LINUX || JUCE_BSD
506+ if (hasPendingLinuxMaximisedState)
507+ return pendingLinuxMaximisedState;
508+
506509 if (auto * peer = getPeer ()) {
507510 return OSUtils::isLinuxWindowMaximised (peer);
508511 } else {
@@ -523,11 +526,12 @@ class PlugDataWindow final : public DocumentWindow
523526#if JUCE_LINUX || JUCE_BSD
524527 if (auto * b = getMaximiseButton ()) {
525528 if (auto * peer = getPeer ()) {
526- bool shouldBeMaximised = OSUtils::isLinuxWindowMaximised (peer);
527- b->setToggleState (!shouldBeMaximised, dontSendNotification);
529+ bool shouldBeMaximised = !isMaximised ();
530+ setPendingLinuxMaximisedState (shouldBeMaximised);
531+ b->setToggleState (shouldBeMaximised, dontSendNotification);
528532
529533 if (!useNativeTitlebar ()) {
530- OSUtils::maximiseLinuxWindow (peer, ! shouldBeMaximised);
534+ OSUtils::maximiseLinuxWindow (peer, shouldBeMaximised);
531535 }
532536 } else {
533537 b->setToggleState (false , dontSendNotification);
@@ -619,6 +623,31 @@ class PlugDataWindow final : public DocumentWindow
619623 }
620624
621625private:
626+ #if JUCE_LINUX || JUCE_BSD
627+ void setPendingLinuxMaximisedState (bool shouldBeMaximised)
628+ {
629+ hasPendingLinuxMaximisedState = true ;
630+ pendingLinuxMaximisedState = shouldBeMaximised;
631+ auto const pendingStateSerial = ++pendingLinuxMaximisedStateSerial;
632+
633+ Timer::callAfterDelay (250 , [_this = SafePointer (this ), pendingStateSerial] {
634+ if (!_this)
635+ return ;
636+
637+ if (_this->pendingLinuxMaximisedStateSerial != pendingStateSerial)
638+ return ;
639+
640+ _this->hasPendingLinuxMaximisedState = false ;
641+
642+ if (auto * b = _this->getMaximiseButton ())
643+ b->setToggleState (_this->isMaximised (), dontSendNotification);
644+
645+ _this->resized ();
646+ _this->repaint ();
647+ });
648+ }
649+ #endif
650+
622651 class MainContentComponent final : public Component
623652 , private ComponentListener
624653 , public MenuBarModel {
@@ -784,5 +813,13 @@ class PlugDataWindow final : public DocumentWindow
784813public:
785814 MainContentComponent* mainComponent = nullptr ;
786815
816+ private:
817+ #if JUCE_LINUX || JUCE_BSD
818+ bool hasPendingLinuxMaximisedState = false ;
819+ bool pendingLinuxMaximisedState = false ;
820+ int pendingLinuxMaximisedStateSerial = 0 ;
821+ #endif
822+
823+ public:
787824 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PlugDataWindow)
788825};
0 commit comments