mirror of
https://github.com/LizardByte/tray.git
synced 2026-12-06 15:12:48 +09:00
refactor: Move platform specific code from QtTrayMenu to tray_linux
This commit is contained in:
1 parent
6b640ef4f1
commit
c49e23d7b1
2 files changed
+6
-5
No files matched your search
@@ -27,11 +27,6 @@ QtTrayMenu::QtTrayMenu(QObject *parent, const bool debug):
|
||||
|
||||
QtTrayMenu::QtTrayMenu(int argc, char **argv, QObject *parent, const bool debug):
|
||||
QObject(parent) {
|
||||
if (qgetenv("WAYLAND_DISPLAY").isEmpty() && qgetenv("DISPLAY").isEmpty()) {
|
||||
// Force fallback to QT platform minimal if no (WAYLAND_)DISPLAY was found
|
||||
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));
|
||||
qWarning("QtTrayMenu: no reachable WAYLAND_DISPLAY or DISPLAY endpoint, forcing QT_QPA_PLATFORM=minimal");
|
||||
}
|
||||
if (QApplication::instance()) {
|
||||
app = dynamic_cast<QApplication *>(QApplication::instance());
|
||||
if (!app) {
|
||||
|
||||
@@ -176,6 +176,12 @@ extern "C" {
|
||||
|
||||
int tray_init(struct tray *tray) {
|
||||
if (tray_linux::qt_tray_menu == nullptr) {
|
||||
// Check if a (wayland_)display is set or fallback to minimal QPA platform
|
||||
if (qgetenv("WAYLAND_DISPLAY").isEmpty() && qgetenv("DISPLAY").isEmpty()) {
|
||||
// Force fallback to QT platform minimal if no (WAYLAND_)DISPLAY was found
|
||||
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));
|
||||
qWarning("QtTrayMenu: no reachable WAYLAND_DISPLAY or DISPLAY endpoint, forcing QT_QPA_PLATFORM=minimal");
|
||||
}
|
||||
// Create a new unique pointer to QtTrayMenu instance
|
||||
tray_linux::qt_tray_menu = std::make_unique<QtTrayMenu>();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user