From 010abe83f54821ac41a6f0c7791e8c368670cf0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 5 Mar 2023 11:37:34 +0100 Subject: [PATCH 1/2] Don't use probably broken QMenuBar::setNativeMenuBar(false) --- src/mixxx.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/mixxx.cpp b/src/mixxx.cpp index f88ce12fa20a..4643f274bfdc 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -217,6 +217,15 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args) mixxx::Translations::initializeTranslations( m_pSettingsManager->settings(), pApp, args.getLocale()); +#ifdef __LINUX__ + // If the desktop features a global menubar and we go fullscreen during + // startup, move the menubar to the window like in slotViewFullScreen() + bool fullscreenPref = m_pSettingsManager->settings()->getValue( + ConfigKey("[Config]", "StartInFullscreen")); + QApplication::setAttribute( + Qt::AA_DontUseNativeMenuBar, + args.getStartInFullscreen() || fullscreenPref); +#endif // __LINUX__ createMenuBar(); m_pMenuBar->hide(); @@ -265,13 +274,6 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { ConfigKey("[Config]", "StartInFullscreen")); if (args.getStartInFullscreen() || fullscreenPref) { showFullScreen(); -#ifdef __LINUX__ - // If the desktop features a global menubar and we go fullscreen during - // startup, move the menubar to the window like in slotViewFullScreen() - if (m_pMenuBar->isNativeMenuBar()) { - m_pMenuBar->setNativeMenuBar(false); - } -#endif } QString resourcePath = pConfig->getResourcePath(); @@ -1438,14 +1440,13 @@ void MixxxMainWindow::slotViewFullScreen(bool toggle) { // Fix for "No menu bar with ubuntu unity in full screen mode" Bug // #885890 and Bug #1076789. Before touching anything here, please read // those bugs. + QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); createMenuBar(); connectMenuBar(); - if (m_pMenuBar->isNativeMenuBar()) { - m_pMenuBar->setNativeMenuBar(false); - } #endif } else { #ifdef __LINUX__ + QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, false); createMenuBar(); connectMenuBar(); #endif From 8e7ff56e504e88032d0be82fd44a963a37b02200 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 6 Mar 2023 22:49:20 +0100 Subject: [PATCH 2/2] fullscreen / Qt::AA_DontUseNativeMenuBar: improve comments --- src/mixxx.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 4643f274bfdc..07bf47210769 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -218,8 +218,12 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args) m_pSettingsManager->settings(), pApp, args.getLocale()); #ifdef __LINUX__ - // If the desktop features a global menubar and we go fullscreen during - // startup, move the menubar to the window like in slotViewFullScreen() + // If the desktop features a global menubar and we'll go fullscreen during + // startup, set Qt::AA_DontUseNativeMenuBar so the menubar is placed in the + // window like it's done in slotViewFullScreen(). On other desktops this + // attribute has no effect. This is a safe alternative to setNativeMenuBar() + // which can cause a crash when using menu shortcuts like Alt+F after resetting + // the menubar. See https://github.com/mixxxdj/mixxx/issues/11320 bool fullscreenPref = m_pSettingsManager->settings()->getValue( ConfigKey("[Config]", "StartInFullscreen")); QApplication::setAttribute( @@ -1437,9 +1441,11 @@ void MixxxMainWindow::slotViewFullScreen(bool toggle) { if (toggle) { showFullScreen(); #ifdef __LINUX__ - // Fix for "No menu bar with ubuntu unity in full screen mode" Bug - // #885890 and Bug #1076789. Before touching anything here, please read + // Fix for "No menu bar with ubuntu unity in full screen mode" (issues + // #885890 and #1076789. Before touching anything here, please read // those bugs. + // Set this attribute instead of calling setNativeMenuBar(false), see + // https://github.com/mixxxdj/mixxx/issues/11320 QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, true); createMenuBar(); connectMenuBar();