Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fullscreen: remove Linux menubar workaround #11259

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 37 additions & 10 deletions src/mixxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down
5 changes: 5 additions & 0 deletions src/mixxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions src/widget/wmainmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down