@@ -96,7 +96,7 @@ AppMenuButtonGroup::AppMenuButtonGroup(Decoration *decoration)
9696 connect (m_resetTimer, &QTimer::timeout, this , &AppMenuButtonGroup::resetButtons);
9797
9898 m_menuLoadFallbackTimer = new QTimer (this );
99- m_menuLoadFallbackTimer->setInterval (2000 );
99+ m_menuLoadFallbackTimer->setInterval (750 );
100100 m_menuLoadFallbackTimer->setSingleShot (true );
101101 connect (m_menuLoadFallbackTimer, &QTimer::timeout, this , [this ]() {
102102 if (!m_menuLoadedOnce) {
@@ -148,6 +148,10 @@ AppMenuButtonGroup::AppMenuButtonGroup(Decoration *decoration)
148148
149149 if (decoratedClient->hasApplicationMenu ()) {
150150 onHasApplicationMenuChanged (true );
151+ } else {
152+ // Initial wait to see if a menu appears later during startup.
153+ // This avoids the title appearing and then shifting.
154+ m_menuLoadFallbackTimer->start (500 );
151155 }
152156}
153157
@@ -366,9 +370,10 @@ void AppMenuButtonGroup::onMenuReadyForSearch()
366370void AppMenuButtonGroup::onHasApplicationMenuChanged (bool hasMenu)
367371{
368372 if (hasMenu) {
369- if (!m_menuLoadedOnce) {
370- m_menuLoadFallbackTimer->start ();
371- }
373+ m_resetTimer->stop ();
374+ m_menuLoadedOnce = false ;
375+ m_menuLoadFallbackTimer->start (750 );
376+ Q_EMIT menuUpdated ();
372377
373378 if (m_isMenuUpdateThrottled) {
374379 m_pendingMenuUpdate = true ;
@@ -386,6 +391,7 @@ void AppMenuButtonGroup::onHasApplicationMenuChanged(bool hasMenu)
386391 // Defer reset to avoid flicker during window closure
387392 m_resetTimer->start ();
388393 m_menuLoadedOnce = false ;
394+ Q_EMIT menuUpdated ();
389395 }
390396}
391397
@@ -468,10 +474,6 @@ void AppMenuButtonGroup::updateAppMenuModel()
468474 return ;
469475 }
470476
471- m_resetTimer->stop ();
472- m_menuLoadFallbackTimer->stop ();
473- m_menuLoadedOnce = true ;
474-
475477 const auto actions = menu->actions ();
476478 const int menuActionCount = actions.count ();
477479
@@ -566,6 +568,12 @@ void AppMenuButtonGroup::updateAppMenuModel()
566568 }
567569 }
568570
571+ if (menuActionCount > 0 ) {
572+ m_resetTimer->stop ();
573+ m_menuLoadFallbackTimer->stop ();
574+ m_menuLoadedOnce = true ;
575+ }
576+
569577 Q_EMIT menuUpdated ();
570578 }
571579}
@@ -682,6 +690,11 @@ bool AppMenuButtonGroup::menuLoadedOnce() const
682690 return m_menuLoadedOnce;
683691}
684692
693+ bool AppMenuButtonGroup::isWaitingForMenu () const
694+ {
695+ return m_menuLoadFallbackTimer && m_menuLoadFallbackTimer->isActive ();
696+ }
697+
685698void AppMenuButtonGroup::popupMenu (QMenu *menu, int buttonIndex)
686699{
687700 // Stop any caching that may be in progress from a previously opened menu.
0 commit comments