diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 00a48742d..3d8826618 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -23,13 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/localstorage.h" #include "window/window_controller.h" #include "window/window_session_controller.h" -#include "media/player/media_player_instance.h" -#include "media/audio/media_audio.h" #include "base/platform/base_platform_info.h" #include "base/platform/linux/base_xcb_utilities_linux.h" -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#include "platform/linux/linux_gsd_media_keys.h" -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION #include "base/call_delayed.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/input_fields.h" @@ -584,17 +579,6 @@ void MainWindow::initHook() { } else { LOG(("Not using Unity launcher counter.")); } - - Media::Player::instance()->updatedNotifier( - ) | rpl::start_with_next([=](const Media::Player::TrackState &state) { - if (!Media::Player::IsStoppedOrStopping(state.state)) { - if (!_gsdMediaKeys) { - _gsdMediaKeys = std::make_unique(); - } - } else if (_gsdMediaKeys) { - _gsdMediaKeys = nullptr; - } - }, lifetime()); #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION updateWaylandDecorationColors(); diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h index 5e06aadbe..0460829af 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.h +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h @@ -25,11 +25,6 @@ typedef struct _GDBusProxy GDBusProxy; #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION namespace Platform { -#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -namespace internal { -class GSDMediaKeys; -} // namespace internal -#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION class MainWindow : public Window::MainWindow { public: @@ -93,8 +88,6 @@ private: bool _appMenuSupported = false; DBusMenuExporter *_mainMenuExporter = nullptr; - std::unique_ptr _gsdMediaKeys; - QMenu *psMainMenu = nullptr; QAction *psLogout = nullptr; QAction *psUndo = nullptr; diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp index 5ffe8a1e0..85800979d 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp @@ -24,6 +24,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_controller.h" #include "core/application.h" +#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION +#include "platform/linux/linux_gsd_media_keys.h" +#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION + #include #include #include @@ -521,6 +525,18 @@ Window::Control GtkKeywordToWindowControl(const QString &keyword) { } // namespace +void SetWatchingMediaKeys(bool watching) { +#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION + static std::unique_ptr Instance; + + if (watching && !Instance) { + Instance = std::make_unique(); + } else if (!watching && Instance) { + Instance = nullptr; + } +#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION +} + void SetApplicationIcon(const QIcon &icon) { QApplication::setWindowIcon(icon); } diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.h b/Telegram/SourceFiles/platform/linux/specific_linux.h index 2bf9d9e61..80584a23d 100644 --- a/Telegram/SourceFiles/platform/linux/specific_linux.h +++ b/Telegram/SourceFiles/platform/linux/specific_linux.h @@ -17,9 +17,6 @@ class LocationPoint; namespace Platform { -inline void SetWatchingMediaKeys(bool watching) { -} - bool InFlatpak(); bool InSnap(); bool IsStaticBinary();