From 56de3194ef1955bf828b0b5c6e1c4aed123e5f8e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 17 Jun 2020 01:23:39 +0400 Subject: [PATCH] Never use custom notifications on Wayland since there are no positioning API --- .../linux/notifications_manager_linux.cpp | 18 ++++++++++++++++-- .../settings/settings_notifications.cpp | 5 +++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index 2c780726a0..51ee31a92f 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "platform/linux/notifications_manager_linux.h" #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION +#include "base/platform/base_platform_info.h" #include "platform/linux/specific_linux.h" #include "history/history.h" #include "lang/lang_keys.h" @@ -70,7 +71,7 @@ void GetSupported() { } Checked = true; - if (Global::NativeNotifications()) { + if (Global::NativeNotifications() && !Platform::IsWayland()) { ComputeSupported(true); } else { ComputeSupported(); @@ -474,7 +475,8 @@ std::unique_ptr Create( #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION GetSupported(); - if (Global::NativeNotifications() && Supported()) { + if ((Global::NativeNotifications() && Supported()) + || Platform::IsWayland()) { return std::make_unique(system); } #endif // !TDESKTOP_DISABLE_DBUS_INTEGRATION @@ -488,6 +490,10 @@ Manager::Private::Private(not_null manager, Type type) , _manager(manager) { qDBusRegisterMetaType(); + if (!Supported()) { + return; + } + const auto serverInformation = GetServerInformation(); const auto capabilities = GetCapabilities(); @@ -520,6 +526,8 @@ void Manager::Private::showNotification( const QString &msg, bool hideNameAndPhoto, bool hideReplyButton) { + if (!Supported()) return; + auto notification = std::make_shared( _manager, title, @@ -558,6 +566,8 @@ void Manager::Private::showNotification( } void Manager::Private::clearAll() { + if (!Supported()) return; + auto temp = base::take(_notifications); for_const (auto ¬ifications, temp) { for_const (auto notification, notifications) { @@ -567,6 +577,8 @@ void Manager::Private::clearAll() { } void Manager::Private::clearFromHistory(not_null history) { + if (!Supported()) return; + auto i = _notifications.find(history->peer->id); if (i != _notifications.cend()) { auto temp = base::take(i.value()); @@ -579,6 +591,8 @@ void Manager::Private::clearFromHistory(not_null history) { } void Manager::Private::clearNotification(PeerId peerId, MsgId msgId) { + if (!Supported()) return; + auto i = _notifications.find(peerId); if (i != _notifications.cend()) { i.value().remove(msgId); diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index 38e166246b..7cc4e4fc68 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -634,6 +634,11 @@ void SetupNotificationsContent( } else if (Platform::IsWindows()) { return tr::lng_settings_use_windows(tr::now); } else if (Platform::IsLinux()) { +#ifdef Q_OS_UNIX + if (Platform::IsWayland()) { + return QString(); + } +#endif // Q_OS_UNIX return tr::lng_settings_use_native_notifications(tr::now); } return QString();