mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Remove SetWatchingMediaKeys
Since SPMediaKeyTap has been removed on Mac, Linux is the only platform where this function is implemented, but that's not really needed due to MPRIS support, so SetWatchingMediaKeys can be dropped entirely
This commit is contained in:
parent
49fed41dfa
commit
dc81f9eeaf
8 changed files with 0 additions and 216 deletions
|
@ -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
|
||||
|
|
|
@ -565,7 +565,6 @@ bool HandleEvent(not_null<QShortcutEvent*> event) {
|
|||
|
||||
void ToggleMediaShortcuts(bool toggled) {
|
||||
Data.toggleMedia(toggled);
|
||||
Platform::SetWatchingMediaKeys(toggled);
|
||||
}
|
||||
|
||||
void ToggleSupportShortcuts(bool toggled) {
|
||||
|
|
|
@ -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 <glibmm.h>
|
||||
#include <giomm.h>
|
||||
|
||||
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<Gio::DBus::Connection> &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<Glib::ustring>(
|
||||
parametersCopy.get_child(0));
|
||||
|
||||
const auto key = base::Platform::GlibVariantCast<Glib::ustring>(
|
||||
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<Gio::DBus::Connection> dbusConnection;
|
||||
|
||||
Glib::ustring service;
|
||||
Glib::ustring objectPath;
|
||||
Glib::ustring interface;
|
||||
uint signalId = 0;
|
||||
bool grabbed = false;
|
||||
};
|
||||
|
||||
GSDMediaKeys::GSDMediaKeys()
|
||||
: _private(std::make_unique<Private>()) {
|
||||
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
|
|
@ -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> _private;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace Platform
|
|
@ -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<internal::GSDMediaKeys> GSDInstance;
|
||||
|
||||
if (watching) {
|
||||
if (!GSDInstance) {
|
||||
GSDInstance = std::make_unique<internal::GSDMediaKeys>();
|
||||
}
|
||||
} else {
|
||||
if (GSDInstance) {
|
||||
GSDInstance = nullptr;
|
||||
}
|
||||
}
|
||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||
}
|
||||
|
||||
void SetApplicationIcon(const QIcon &icon) {
|
||||
QApplication::setWindowIcon(icon);
|
||||
}
|
||||
|
|
|
@ -243,9 +243,6 @@ ApplicationDelegate *_sharedDelegate = nil;
|
|||
|
||||
namespace Platform {
|
||||
|
||||
void SetWatchingMediaKeys(bool watching) {
|
||||
}
|
||||
|
||||
void SetApplicationIcon(const QIcon &icon) {
|
||||
NSImage *image = nil;
|
||||
if (!icon.isNull()) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -16,9 +16,6 @@ class LocationPoint;
|
|||
|
||||
namespace Platform {
|
||||
|
||||
inline void SetWatchingMediaKeys(bool watching) {
|
||||
}
|
||||
|
||||
inline void IgnoreApplicationActivationRightNow() {
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue