diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index b79769ec7..f44b85137 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -894,8 +894,6 @@ PRIVATE platform/linux/linux_desktop_environment.h platform/linux/linux_gdk_helper.cpp platform/linux/linux_gdk_helper.h - platform/linux/linux_gsd_media_keys.cpp - platform/linux/linux_gsd_media_keys.h platform/linux/linux_gtk_integration_dummy.cpp platform/linux/linux_gtk_integration_p.h platform/linux/linux_gtk_integration.cpp @@ -1197,8 +1195,6 @@ endif() if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION) remove_target_sources(Telegram ${src_loc} - platform/linux/linux_gsd_media_keys.cpp - platform/linux/linux_gsd_media_keys.h platform/linux/linux_mpris_support.cpp platform/linux/linux_mpris_support.h platform/linux/linux_xdp_file_dialog.cpp diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index 654890071..93d350d91 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -565,7 +565,6 @@ bool HandleEvent(not_null event) { void ToggleMediaShortcuts(bool toggled) { Data.toggleMedia(toggled); - Platform::SetWatchingMediaKeys(toggled); } void ToggleSupportShortcuts(bool toggled) { diff --git a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.cpp b/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.cpp deleted file mode 100644 index c5f19e03f..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "platform/linux/linux_gsd_media_keys.h" - -#include "core/sandbox.h" -#include "media/player/media_player_instance.h" -#include "base/platform/linux/base_linux_glibmm_helper.h" -#include "base/platform/linux/base_linux_dbus_utilities.h" - -#include -#include - -namespace Platform { -namespace internal { -namespace { - -constexpr auto kService = "org.gnome.SettingsDaemon.MediaKeys"_cs; -constexpr auto kOldService = "org.gnome.SettingsDaemon"_cs; -constexpr auto kMATEService = "org.mate.SettingsDaemon"_cs; -constexpr auto kObjectPath = "/org/gnome/SettingsDaemon/MediaKeys"_cs; -constexpr auto kMATEObjectPath = "/org/mate/SettingsDaemon/MediaKeys"_cs; -constexpr auto kInterface = kService; -constexpr auto kMATEInterface = "org.mate.SettingsDaemon.MediaKeys"_cs; - -void KeyPressed( - const Glib::RefPtr &connection, - const Glib::ustring &sender_name, - const Glib::ustring &object_path, - const Glib::ustring &interface_name, - const Glib::ustring &signal_name, - const Glib::VariantContainerBase ¶meters) { - try { - auto parametersCopy = parameters; - - const auto app = base::Platform::GlibVariantCast( - parametersCopy.get_child(0)); - - const auto key = base::Platform::GlibVariantCast( - parametersCopy.get_child(1)); - - if (app != QCoreApplication::applicationName().toStdString()) { - return; - } - - Core::Sandbox::Instance().customEnterFromEventLoop([&] { - if (key == "Play") { - Media::Player::instance()->playPause(); - } else if (key == "Stop") { - Media::Player::instance()->stop(); - } else if (key == "Next") { - Media::Player::instance()->next(); - } else if (key == "Previous") { - Media::Player::instance()->previous(); - } - }); - } catch (...) { - } -} - -} // namespace - -class GSDMediaKeys::Private { -public: - Glib::RefPtr dbusConnection; - - Glib::ustring service; - Glib::ustring objectPath; - Glib::ustring interface; - uint signalId = 0; - bool grabbed = false; -}; - -GSDMediaKeys::GSDMediaKeys() -: _private(std::make_unique()) { - try { - _private->dbusConnection = Gio::DBus::Connection::get_sync( - Gio::DBus::BusType::BUS_TYPE_SESSION); - - if (base::Platform::DBus::NameHasOwner( - _private->dbusConnection, - std::string(kService))) { - _private->service = std::string(kService); - _private->objectPath = std::string(kObjectPath); - _private->interface = std::string(kInterface); - } else if (base::Platform::DBus::NameHasOwner( - _private->dbusConnection, - std::string(kOldService))) { - _private->service = std::string(kOldService); - _private->objectPath = std::string(kObjectPath); - _private->interface = std::string(kInterface); - } else if (base::Platform::DBus::NameHasOwner( - _private->dbusConnection, - std::string(kMATEService))) { - _private->service = std::string(kMATEService); - _private->objectPath = std::string(kMATEObjectPath); - _private->interface = std::string(kMATEInterface); - } else { - return; - } - - _private->dbusConnection->call_sync( - _private->objectPath, - _private->interface, - "GrabMediaPlayerKeys", - base::Platform::MakeGlibVariant(std::tuple{ - Glib::ustring( - QCoreApplication::applicationName() - .toStdString()), - uint(0), - }), - _private->service); - - _private->grabbed = true; - - _private->signalId = _private->dbusConnection->signal_subscribe( - sigc::ptr_fun(KeyPressed), - _private->service, - _private->interface, - "MediaPlayerKeyPressed", - _private->objectPath); - } catch (...) { - } -} - -GSDMediaKeys::~GSDMediaKeys() { - if (_private->dbusConnection) { - if (_private->signalId != 0) { - _private->dbusConnection->signal_unsubscribe(_private->signalId); - } - - if (_private->grabbed) { - try { - _private->dbusConnection->call_sync( - _private->objectPath, - _private->interface, - "ReleaseMediaPlayerKeys", - base::Platform::MakeGlibVariant(std::tuple{ - Glib::ustring( - QCoreApplication::applicationName() - .toStdString()) - }), - _private->service); - - _private->grabbed = false; - } catch (...) { - } - } - } -} - -} // namespace internal -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.h b/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.h deleted file mode 100644 index 10b854d6e..000000000 --- a/Telegram/SourceFiles/platform/linux/linux_gsd_media_keys.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -namespace Platform { -namespace internal { - -class GSDMediaKeys { -public: - GSDMediaKeys(); - - GSDMediaKeys(const GSDMediaKeys &other) = delete; - GSDMediaKeys &operator=(const GSDMediaKeys &other) = delete; - GSDMediaKeys(GSDMediaKeys &&other) = delete; - GSDMediaKeys &operator=(GSDMediaKeys &&other) = delete; - - ~GSDMediaKeys(); - -private: - class Private; - const std::unique_ptr _private; -}; - -} // namespace internal -} // namespace Platform diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index b59bcefb2..f9c0fa1db 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -28,7 +28,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/platform/linux/base_linux_dbus_utilities.h" #include "base/platform/linux/base_linux_xdp_utilities.h" #include "platform/linux/linux_xdp_file_dialog.h" -#include "platform/linux/linux_gsd_media_keys.h" #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #ifndef DESKTOP_APP_DISABLE_X11_INTEGRATION @@ -455,22 +454,6 @@ void SetDarkMode() { } // namespace -void SetWatchingMediaKeys(bool watching) { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION - static std::unique_ptr GSDInstance; - - if (watching) { - if (!GSDInstance) { - GSDInstance = std::make_unique(); - } - } else { - if (GSDInstance) { - GSDInstance = nullptr; - } - } -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION -} - void SetApplicationIcon(const QIcon &icon) { QApplication::setWindowIcon(icon); } diff --git a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm index edd85a666..eee9c89d6 100644 --- a/Telegram/SourceFiles/platform/mac/specific_mac_p.mm +++ b/Telegram/SourceFiles/platform/mac/specific_mac_p.mm @@ -243,9 +243,6 @@ ApplicationDelegate *_sharedDelegate = nil; namespace Platform { -void SetWatchingMediaKeys(bool watching) { -} - void SetApplicationIcon(const QIcon &icon) { NSImage *image = nil; if (!icon.isNull()) { diff --git a/Telegram/SourceFiles/platform/platform_specific.h b/Telegram/SourceFiles/platform/platform_specific.h index 709ea0058..0dec322f7 100644 --- a/Telegram/SourceFiles/platform/platform_specific.h +++ b/Telegram/SourceFiles/platform/platform_specific.h @@ -27,7 +27,6 @@ enum class SystemSettingsType { Audio, }; -void SetWatchingMediaKeys(bool watching); void SetApplicationIcon(const QIcon &icon); QString SingleInstanceLocalServerName(const QString &hash); PermissionStatus GetPermissionStatus(PermissionType type); diff --git a/Telegram/SourceFiles/platform/win/specific_win.h b/Telegram/SourceFiles/platform/win/specific_win.h index d35c3fcf3..84a8c8250 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.h +++ b/Telegram/SourceFiles/platform/win/specific_win.h @@ -16,9 +16,6 @@ class LocationPoint; namespace Platform { -inline void SetWatchingMediaKeys(bool watching) { -} - inline void IgnoreApplicationActivationRightNow() { }