Skip to content

Commit

Permalink
WIP/FIX Debug fullscreen & menubar toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jun 8, 2023
1 parent 0761cb6 commit 0c65b7f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) {
}
} else if (event->type() == QEvent::WindowStateChange) {
#ifndef __APPLE__
qWarning() << "$ WindowStateChange:" << windowState();
if (windowState() == m_prevState) {
// Ignore no-op. This happens if another window is raised above
// MixxxMianWindow, e.g. DlgPeferences. In such a case event->oldState()
Expand All @@ -1281,13 +1282,16 @@ bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) {
const bool isFullScreenNow = windowState() & Qt::WindowFullScreen;
if ((isFullScreenNow && !wasFullScreen) ||
(!isFullScreenNow && wasFullScreen)) {
qWarning() << "$ fullscreen changed, now"
<< (isFullScreenNow ? "fullscreen" : "window");
#ifdef __LINUX__
// 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
if (m_supportsGlobalMenuBar) {
qWarning() << "$ global menu > rebuild";
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar, isFullScreenNow);
createMenuBar();
connectMenuBar();
Expand Down
17 changes: 11 additions & 6 deletions src/widget/wmainmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,9 @@ void WMainMenuBar::connectMenuToSlotShowMenuBar(const QMenu* pMenu) {
}

void WMainMenuBar::slotToggleMenuBar() {
qWarning() << " # toggle menubar";
if (isNativeMenuBar()) {
qWarning() << " # (ignore)";
return;
}

Expand All @@ -760,6 +762,7 @@ void WMainMenuBar::slotToggleMenuBar() {
}

void WMainMenuBar::showMenuBar() {
qWarning() << " # show menubar";
if (isNativeMenuBar()) {
return;
}
Expand All @@ -768,20 +771,22 @@ void WMainMenuBar::showMenuBar() {
// Left/Right keys, i.e. we're stuck with the triggered menu.
// Current active action can be none, user-requested (hotkey) or auto-selected
// (first, behaviour differs per platform and/or Qt version).
// Workaround: reselect the active action manually after unhiding
// Workaround: reselect the active action after unhiding
QAction* pAct = activeAction();
setMinimumHeight(sizeHint().height());
// If there was a menu selected before, reselect that.
if (pAct) {
// Note: pAct can be be nullptr (no-op). Though, it is is, no menu is
// Note: pAct can be be nullptr (no-op). Though, if it is, no menu is
// selected BUT hovering any of them will instantly open that (no click required).
setActiveAction(pAct); // nullptr is no-op
setActiveAction(pAct);
}
// TODO Alternativley, activate the first menu?
// setActiveAction(pAct ? pAct : actions().first());
// TODO Alternativley, always activate the first menu?
// else {
// setActiveAction(pAct ? pAct : actions().first());
// }
}

void WMainMenuBar::hideMenuBar() {
qWarning() << " # hide menubar";
if (isNativeMenuBar()) {
return;
}
Expand Down

0 comments on commit 0c65b7f

Please sign in to comment.