Fix gnome d-dus shortcuts backend

This commit is contained in:
Jonas Kvinge
2019-01-08 23:25:50 +01:00
parent 696dc0051e
commit 411cb27ead
3 changed files with 13 additions and 9 deletions

View File

@@ -37,9 +37,9 @@
#include "globalshortcutbackend.h"
#include "globalshortcutbackend-dbus.h"
const char *GlobalShortcutBackendDBus::kGsdService = "org.gnome.SettingsDaemon";
const char *GlobalShortcutBackendDBus::kGsdService = "org.gnome.SettingsDaemon.MediaKeys";
const char *GlobalShortcutBackendDBus::kGsdService2 = "org.gnome.SettingsDaemon";
const char *GlobalShortcutBackendDBus::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys";
const char *GlobalShortcutBackendDBus::kGsdInterface = "org.gnome.SettingsDaemon.MediaKeys";
GlobalShortcutBackendDBus::GlobalShortcutBackendDBus(GlobalShortcuts *parent)
: GlobalShortcutBackend(parent),
@@ -52,14 +52,18 @@ bool GlobalShortcutBackendDBus::DoRegister() {
qLog(Debug) << "Registering";
// Check if the GSD service is available
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService)) {
qLog(Warning) << "Gnome settings daemon not registered";
return false;
if (!interface_) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService)) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(kGsdService, kGsdPath, QDBusConnection::sessionBus(), this);
}
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService2)) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(kGsdService2, kGsdPath, QDBusConnection::sessionBus(), this);
}
}
if (!interface_) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(kGsdService, kGsdPath, QDBusConnection::sessionBus(), this);
qLog(Warning) << "Gnome settings daemon not registered";
return false;
}
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toTime_t());

View File

@@ -46,8 +46,8 @@ class GlobalShortcutBackendDBus : public GlobalShortcutBackend {
~GlobalShortcutBackendDBus();
static const char *kGsdService;
static const char *kGsdService2;
static const char *kGsdPath;
static const char *kGsdInterface;
protected:
bool RegisterInNewThread() const { return true; }

View File

@@ -134,7 +134,7 @@ GlobalShortcuts::Shortcut GlobalShortcuts::AddShortcut(const QString &id, const
bool GlobalShortcuts::IsGsdAvailable() const {
#ifdef HAVE_DBUS
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutBackendDBus::kGsdService);
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutBackendDBus::kGsdService) || QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutBackendDBus::kGsdService2);
#else
return false;
#endif