Skip to content

Commit a0381e7

Browse files
authored
refactor: Move platform specific code from QtTrayMenu to tray_linux (#137)
1 parent 6b640ef commit a0381e7

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/QtTrayMenu.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ QtTrayMenu::QtTrayMenu(QObject *parent, const bool debug):
2727

2828
QtTrayMenu::QtTrayMenu(int argc, char **argv, QObject *parent, const bool debug):
2929
QObject(parent) {
30-
if (qgetenv("WAYLAND_DISPLAY").isEmpty() && qgetenv("DISPLAY").isEmpty()) {
31-
// Force fallback to QT platform minimal if no (WAYLAND_)DISPLAY was found
32-
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));
33-
qWarning("QtTrayMenu: no reachable WAYLAND_DISPLAY or DISPLAY endpoint, forcing QT_QPA_PLATFORM=minimal");
34-
}
3530
if (QApplication::instance()) {
3631
app = dynamic_cast<QApplication *>(QApplication::instance());
3732
if (!app) {

src/tray_linux.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ extern "C" {
176176

177177
int tray_init(struct tray *tray) {
178178
if (tray_linux::qt_tray_menu == nullptr) {
179+
// Check if a (wayland_)display is set or fallback to minimal QPA platform
180+
if (qgetenv("WAYLAND_DISPLAY").isEmpty() && qgetenv("DISPLAY").isEmpty()) {
181+
// Force fallback to QT platform minimal if no (WAYLAND_)DISPLAY was found
182+
qputenv("QT_QPA_PLATFORM", QByteArrayLiteral("minimal"));
183+
qWarning("QtTrayMenu: no reachable WAYLAND_DISPLAY or DISPLAY endpoint, forcing QT_QPA_PLATFORM=minimal");
184+
}
179185
// Create a new unique pointer to QtTrayMenu instance
180186
tray_linux::qt_tray_menu = std::make_unique<QtTrayMenu>();
181187
}

0 commit comments

Comments
 (0)