#include "mixxxmainwindow.h"
#include <QDesktopServices>
#include <QFileDialog>
#include "widget/wglwidget.h"
#ifdef MIXXX_USE_QOPENGL
#include "widget/tooltipqopengl.h"
#include "widget/winitialglwidget.h"
#else
#include <QGLFormat>
#endif
#include <QUrl>
#ifdef __LINUX__
#include <QtDBus>
#endif
#include <QtDebug>
#include "dialog/dlgabout.h"
#include "dialog/dlgdevelopertools.h"
#include "dialog/dlgkeywheel.h"
#include "effects/effectsmanager.h"
#include "moc_mixxxmainwindow.cpp"
#include "preferences/constants.h"
#include "preferences/dialog/dlgpreferences.h"
#ifdef __BROADCAST__
#include "broadcast/broadcastmanager.h"
#endif
#include "control/controlindicatortimer.h"
#include "controllers/controllermanager.h"
#include "controllers/keyboard/keyboardeventfilter.h"
#include "database/mixxxdb.h"
#include "library/library.h"
#include "library/library_prefs.h"
#ifdef __ENGINEPRIME__
#include "library/export/libraryexporter.h"
#endif
#include "library/trackcollection.h"
#include "library/trackcollectionmanager.h"
#include "mixer/playerinfo.h"
#include "mixer/playermanager.h"
#include "preferences/settingsmanager.h"
#include "recording/recordingmanager.h"
#include "skin/legacy/launchimage.h"
#include "skin/skinloader.h"
#include "soundio/soundmanager.h"
#include "sources/soundsourceproxy.h"
#include "track/track.h"
#include "util/debug.h"
#include "util/experiment.h"
#include "util/font.h"
#include "util/logger.h"
#include "util/math.h"
#include "util/sandbox.h"
#include "util/screensaver.h"
#include "util/time.h"
#include "util/timer.h"
#include "util/translations.h"
#include "util/versionstore.h"
#include "util/widgethelper.h"
#include "waveform/guitick.h"
#include "waveform/sharedglcontext.h"
#include "waveform/visualsmanager.h"
#include "waveform/waveformwidgetfactory.h"
#include "widget/wmainmenubar.h"
#ifdef __VINYLCONTROL__
#include "vinylcontrol/vinylcontrolmanager.h"
#endif
#if defined(Q_OS_LINUX)
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
// Xlibint.h predates C++ and defines macros which conflict
// with references to std::max and std::min
#undef max
#undef min
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtX11Extras/QX11Info>
#endif
#endif
namespace {
#ifdef __LINUX__
// Detect if the desktop supports a global menu to decide whether we need to rebuild
// and reconnect the menu bar when switching to/from fullscreen mode.
// Compared to QMenuBar::isNativeMenuBar() (requires a set menu bar) and
// Qt::AA_DontUseNativeMenuBar, which may both change, this is way more reliable
// since it's rather unlikely that the Appmenu.Registrar service is unloaded/stopped
// while Mixxx is running.
// This is a reimplementation of QGenericUnixTheme > checkDBusGlobalMenuAvailable()
inline bool supportsGlobalMenu() {
#ifndef QT_NO_DBUS
QDBusConnection conn = QDBusConnection::sessionBus();
if (const auto iface = conn.interface()) {
return iface->isServiceRegistered("com.canonical.AppMenu.Registrar");
}
#endif
return false;
}
#endif
} // namespace
MixxxMainWindow::MixxxMainWindow(std::shared_ptr<mixxx::CoreServices> pCoreServices)
: m_pCoreServices(pCoreServices),
m_pCentralWidget(nullptr),
m_pLaunchImage(nullptr),
m_pGuiTick(nullptr),
#ifdef __LINUX__
m_supportsGlobalMenuBar(supportsGlobalMenu()),
#endif
m_pDeveloperToolsDlg(nullptr),
m_pPrefDlg(nullptr),
m_toolTipsCfg(mixxx::TooltipsPreference::TOOLTIPS_ON) {
DEBUG_ASSERT(pCoreServices);
// These depend on the settings
#ifdef __LINUX__
// 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