diff --git a/src/main.cpp b/src/main.cpp index 0ebabc63..92d5d08d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,6 +25,7 @@ #include "src/utils/dbusutils.h" #include #include +#include #endif int waitAfterConnecting(int delay, QCoreApplication& app) @@ -41,11 +42,8 @@ int waitAfterConnecting(int delay, QCoreApplication& app) void wayland_hacks() { // Workaround to https://github.com/ksnip/ksnip/issues/416 - QByteArray currentDesktop = qgetenv("XDG_CURRENT_DESKTOP").toLower(); - QByteArray sessionDesktop = qgetenv("XDG_SESSION_DESKTOP").toLower(); - QByteArray sessionType = qgetenv("XDG_SESSION_TYPE").toLower(); - if (sessionType.contains("wayland") && (currentDesktop.contains("gnome") || - sessionDesktop.contains("gnome"))) { + DesktopInfo info; + if (info.windowManager() == DesktopInfo::GNOME) { qputenv("QT_QPA_PLATFORM", "xcb"); } } diff --git a/src/utils/desktopinfo.cpp b/src/utils/desktopinfo.cpp index 20a2eb09..c2d6d703 100644 --- a/src/utils/desktopinfo.cpp +++ b/src/utils/desktopinfo.cpp @@ -26,16 +26,26 @@ bool DesktopInfo::waylandDectected() DesktopInfo::WM DesktopInfo::windowManager() { DesktopInfo::WM res = DesktopInfo::OTHER; - if (XDG_CURRENT_DESKTOP.contains(QLatin1String("GNOME"), - Qt::CaseInsensitive) || - !GNOME_DESKTOP_SESSION_ID.isEmpty()) { - res = DesktopInfo::GNOME; - } else if (XDG_CURRENT_DESKTOP.contains(QLatin1String("sway"), - Qt::CaseInsensitive)) { - res = DesktopInfo::SWAY; - } else if (!KDE_FULL_SESSION.isEmpty() || - DESKTOP_SESSION == QLatin1String("kde-plasma")) { - res = DesktopInfo::KDE; + QStringList desktops = XDG_CURRENT_DESKTOP.split(QChar(':')); + for (auto & desktop : desktops) { + if (desktop.contains(QLatin1String("GNOME"),Qt::CaseInsensitive)) { + return DesktopInfo::GNOME; + } + if (desktop.contains(QLatin1String("sway"),Qt::CaseInsensitive)) { + return DesktopInfo::SWAY; + } + if (desktop.contains(QLatin1String("kde-plasma"))) { + return DesktopInfo::KDE; + } } + + if (!GNOME_DESKTOP_SESSION_ID.isEmpty()) { + return DesktopInfo::GNOME; + } + + if (!KDE_FULL_SESSION.isEmpty()) { + return DesktopInfo::KDE; + } + return res; }