From 04cfd598e2c8d3c61350237876e7e361ca75aced Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 22 Jan 2020 17:02:27 +0400 Subject: [PATCH] Use appindicator in flatpak and fix desktop environment detection, add pavucontrol-qt --- .../linux/linux_desktop_environment.cpp | 29 ++++++++++--------- .../linux/linux_desktop_environment.h | 10 ------- .../platform/linux/specific_linux.cpp | 1 + 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp index cfd59770f..5fff698f3 100644 --- a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp +++ b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.cpp @@ -7,6 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "platform/linux/linux_desktop_environment.h" +#include "platform/linux/specific_linux.h" + #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION #include #endif @@ -26,7 +28,14 @@ Type Compute() { auto xdgCurrentDesktop = GetEnv("XDG_CURRENT_DESKTOP").toLower(); auto list = xdgCurrentDesktop.split(':', QString::SkipEmptyParts); auto desktopSession = GetEnv("DESKTOP_SESSION").toLower(); + auto slash = desktopSession.lastIndexOf('/'); auto kdeSession = GetEnv("KDE_SESSION_VERSION"); + + // DESKTOP_SESSION can contain a path + if (slash != -1) { + desktopSession = desktopSession.mid(slash + 1); + } + if (!list.isEmpty()) { if (list.contains("unity")) { // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity @@ -35,8 +44,6 @@ Type Compute() { return Type::Gnome; } return Type::Unity; - } else if (list.contains("xfce")) { - return Type::XFCE; } else if (list.contains("pantheon")) { return Type::Pantheon; } else if (list.contains("gnome")) { @@ -53,7 +60,7 @@ Type Compute() { } if (!desktopSession.isEmpty()) { - if (desktopSession == qstr("gnome") || desktopSession == qstr("mate")) { + if (desktopSession == qstr("gnome")) { return Type::Gnome; } else if (desktopSession == qstr("kde4") || desktopSession == qstr("kde-plasma")) { return Type::KDE4; @@ -63,10 +70,6 @@ Type Compute() { return Type::KDE4; } return Type::KDE3; - } else if (desktopSession.indexOf(qstr("xfce")) >= 0 || desktopSession == qstr("xubuntu")) { - return Type::XFCE; - } else if (desktopSession == qstr("awesome")) { - return Type::Awesome; } } @@ -95,9 +98,7 @@ Type ComputeAndLog() { case Type::KDE5: return "KDE5"; case Type::Ubuntu: return "Ubuntu"; case Type::Unity: return "Unity"; - case Type::XFCE: return "XFCE"; case Type::Pantheon: return "Pantheon"; - case Type::Awesome: return "Awesome"; } return QString::number(static_cast(result)); }; @@ -114,15 +115,17 @@ Type Get() { } bool TryQtTrayIcon() { - return !IsPantheon() && !IsAwesome(); + return !IsPantheon(); } bool PreferAppIndicatorTrayIcon() { - return IsXFCE() || IsUnity() || IsUbuntu() || + return (InSandbox() && !IsKDE()) + || IsUnity() + || IsUbuntu() #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION - (IsGnome() && QDBusInterface("org.kde.StatusNotifierWatcher", "/").isValid()); + || (IsGnome() && QDBusInterface("org.kde.StatusNotifierWatcher", "/").isValid()); #else - IsGnome(); + || IsGnome(); #endif } diff --git a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.h b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.h index e8291b240..129b9ef9f 100644 --- a/Telegram/SourceFiles/platform/linux/linux_desktop_environment.h +++ b/Telegram/SourceFiles/platform/linux/linux_desktop_environment.h @@ -18,9 +18,7 @@ enum class Type { KDE5, Ubuntu, Unity, - XFCE, Pantheon, - Awesome, }; Type Get(); @@ -53,18 +51,10 @@ inline bool IsUnity() { return Get() == Type::Unity; } -inline bool IsXFCE() { - return Get() == Type::XFCE; -} - inline bool IsPantheon() { return Get() == Type::Pantheon; } -inline bool IsAwesome() { - return Get() == Type::Awesome; -} - bool TryQtTrayIcon(); bool PreferAppIndicatorTrayIcon(); diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index a085956ac..07c371d2e 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -384,6 +384,7 @@ bool OpenSystemSettings(SystemSettingsType type) { } else if (DesktopEnvironment::IsGnome()) { add("gnome-control-center sound"); } + add("pavucontrol-qt"); add("pavucontrol"); add("alsamixergui"); return ranges::find_if(options, [](const QString &command) {