diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 42a33934e1e1..60555b502ec2 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -168,6 +168,10 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args) m_toolTipsCfg(mixxx::TooltipsPreference::TOOLTIPS_ON), m_runtime_timer("MixxxMainWindow::runtime"), m_cmdLineArgs(args), +#ifdef __LINUX__ + m_recreateMenubarOnFullscreenToggle(false), + m_moveMenuBarToWindow(false), +#endif m_pTouchShift(nullptr) { m_runtime_timer.start(); mixxx::Time::start(); @@ -215,9 +219,24 @@ MixxxMainWindow::MixxxMainWindow(QApplication* pApp, const CmdlineArgs& args) // Menubar depends on translations. mixxx::Translations::initializeTranslations( - m_pSettingsManager->settings(), pApp, args.getLocale()); + m_pSettingsManager->settings(), pApp, args.getLocale()); createMenuBar(); + +#ifdef __LINUX__ + // If true this will recreate and reconnect the mainmenu bar when toggling + // fullscreen in order to fix + // "No menu bar with ubuntu unity in full screen mode" + // https://github.com/mixxxdj/mixxx/issues/6072 (bugs #885890 and #1076789). + // Before touching anything here, please read those bugs. + // 'unity' seems to be the only affectde desktop environment. Test for other DEs + // if required. + // Alternative global menus work without this currently, e.g. vala-panel-appmenu + m_recreateMenubarOnFullscreenToggle = + QString::fromLocal8Bit(qgetenv("XDG_SESSION_DESKTOP")) == "unity"; + m_moveMenuBarToWindow = m_pMenuBar->isNativeMenuBar(); +#endif + m_pMenuBar->hide(); initializeWindow(); @@ -265,6 +284,13 @@ 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 + if (m_moveMenuBarToWindow) { + m_pMenuBar->setNativeMenuBar(false); + } +#endif } QString resourcePath = pConfig->getResourcePath(); @@ -1430,19 +1456,20 @@ 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 - // those bugs. - createMenuBar(); - connectMenuBar(); - if (m_pMenuBar->isNativeMenuBar()) { - m_pMenuBar->setNativeMenuBar(false); + if (m_recreateMenubarOnFullscreenToggle) { + createMenuBar(); + connectMenuBar(); + if (m_pMenuBar->isNativeMenuBar()) { + m_pMenuBar->setNativeMenuBar(false); + } } #endif } else { #ifdef __LINUX__ - createMenuBar(); - connectMenuBar(); + if (m_recreateMenubarOnFullscreenToggle) { + createMenuBar(); + connectMenuBar(); + } #endif showNormal(); } diff --git a/src/mixxx.h b/src/mixxx.h index 32fdb38ed6f1..168414835700 100644 --- a/src/mixxx.h +++ b/src/mixxx.h @@ -181,6 +181,11 @@ class MixxxMainWindow : public QMainWindow { const CmdlineArgs& m_cmdLineArgs; +#ifdef __LINUX__ + bool m_recreateMenubarOnFullscreenToggle; + bool m_moveMenuBarToWindow; +#endif + ControlPushButton* m_pTouchShift; mixxx::ScreenSaverPreference m_inhibitScreensaver; diff --git a/src/widget/wmainmenubar.cpp b/src/widget/wmainmenubar.cpp index 1c7180536de1..033daba76694 100644 --- a/src/widget/wmainmenubar.cpp +++ b/src/widget/wmainmenubar.cpp @@ -691,6 +691,11 @@ void WMainMenuBar::createVisibilityControl(QAction* pAction, &WMainMenuBar::internalOnNewSkinLoaded, pConnection, &VisibilityControlConnection::slotReconnectControl); + // reconnect when menu bar was recreated after toggling fullscreen + connect(this, + &WMainMenuBar::internalFullScreenStateChange, + pConnection, + &VisibilityControlConnection::slotReconnectControl); connect(this, &WMainMenuBar::internalOnNewSkinAboutToLoad, pConnection,