Skip to content

Commit

Permalink
fullscreen: workaround window manager consuming fullscreen hotkey
Browse files Browse the repository at this point in the history
the window manager (xfwm4) hotkey and the Mixxx hotkey are identical, and the keystroke
is consumed by the window manager thus it doesn't reach Mixxx.
Catch the QWindowStateChangeEvent and emit fullScreenChanged(isFullScreen()) manually
to toggle the Fullscreen checkbox and hide the menubar when going fullscreen.
  • Loading branch information
ronso0 committed Feb 25, 2023
1 parent 801c55c commit 167c569
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,25 @@ bool MixxxMainWindow::eventFilter(QObject* obj, QEvent* event) {
return true;
}
}
#ifdef __LINUX__
} else if (event->type() == QEvent::WindowStateChange) {
// detect if we entered or quit fullscreen mode
QWindowStateChangeEvent* changeEvent =
static_cast<QWindowStateChangeEvent*>(event);
bool wasFullScreen = changeEvent->oldState() == Qt::WindowFullScreen;
if ((isFullScreen() && !wasFullScreen) ||
(!isFullScreen() && wasFullScreen)) {
if (isFullScreen() && !wasFullScreen) {
qWarning() << " WindowStateChange: enter fullscreen";
} else {
qWarning() << " WindowStateChange: leave fullscreen";
}
qWarning() << " emit fullScreenChanged(" << isFullScreen() << ")";
// this will toggle the Fullscreen checkbox and hide the menubar if
// we go fullscreen
emit fullScreenChanged(isFullScreen());
}
#endif
}
// standard event processing
return QMainWindow::eventFilter(obj, event);
Expand Down
13 changes: 13 additions & 0 deletions src/widget/wmainmenubar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,28 @@ void WMainMenuBar::initialize() {
shortcuts << QKeySequence("F11");
#endif
QKeySequence osShortcut = QKeySequence::FullScreen;
qWarning() << "##";
qWarning() << "## fullscreen OS hotkey:" << osShortcut.toString();
qWarning() << "## osShortcut.isEmpty:" << osShortcut.isEmpty();
// Funnily this returns 1 = QKeySequence::PartialMatch even though
// KeySequence::FullScreen is empty
qWarning() << "## osShortcut == F11:" << osShortcut.matches(shortcuts.first());
// Note(ronso0) Only add the OS shortcut if it's not empty and not F11.
// In some Linux distros the window managers doesn't pass the OS fullscreen
// key sequence to Mixxx for some reason.
// Both adding an empty key sequence or the same sequence twice can render
// the fullscreen shortcut nonfunctional.
// https://bugs.launchpad.net/mixxx/+bug/1882474 PR #3011
if (!osShortcut.isEmpty() && !shortcuts.contains(osShortcut)) {
qWarning() << "## add OS hotkey";
shortcuts << osShortcut;
int i = 1;
for (auto ks : shortcuts) {
qWarning() << "##" << i << ks.toString();
i++;
}
}
qWarning() << "##";

pViewFullScreen->setShortcuts(shortcuts);
pViewFullScreen->setShortcutContext(Qt::ApplicationShortcut);
Expand Down

0 comments on commit 167c569

Please sign in to comment.