Permalink
Browse files

Fix global shortcuts using GSD D-Bus backend (#6251)

  • Loading branch information...
jonaski authored and hatstand committed Jan 9, 2019
1 parent 35386a1 commit 681f986f0fc87847c18d44b76c75f3c08cca0247
Showing with 21 additions and 11 deletions.
  1. +3 −1 src/core/globalshortcuts.cpp
  2. +17 −9 src/core/gnomeglobalshortcutbackend.cpp
  3. +1 −1 src/core/gnomeglobalshortcutbackend.h
@@ -150,7 +150,9 @@ GlobalShortcuts::Shortcut GlobalShortcuts::AddShortcut(
bool GlobalShortcuts::IsGsdAvailable() const {
#ifdef HAVE_DBUS
return QDBusConnection::sessionBus().interface()->isServiceRegistered(
GnomeGlobalShortcutBackend::kGsdService);
GnomeGlobalShortcutBackend::kGsdService) ||
QDBusConnection::sessionBus().interface()->isServiceRegistered(
GnomeGlobalShortcutBackend::kGsdService2);
#else // HAVE_DBUS
return false;
#endif
@@ -37,11 +37,11 @@
#endif

const char* GnomeGlobalShortcutBackend::kGsdService =
"org.gnome.SettingsDaemon.MediaKeys";
const char* GnomeGlobalShortcutBackend::kGsdService2 =
"org.gnome.SettingsDaemon";
const char* GnomeGlobalShortcutBackend::kGsdPath =
"/org/gnome/SettingsDaemon/MediaKeys";
const char* GnomeGlobalShortcutBackend::kGsdInterface =
"org.gnome.SettingsDaemon.MediaKeys";

GnomeGlobalShortcutBackend::GnomeGlobalShortcutBackend(GlobalShortcuts* parent)
: GlobalShortcutBackend(parent),
@@ -50,17 +50,25 @@ GnomeGlobalShortcutBackend::GnomeGlobalShortcutBackend(GlobalShortcuts* parent)

bool GnomeGlobalShortcutBackend::DoRegister() {
#ifdef HAVE_DBUS

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_) {
// Check if the GSD service is available
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 =
@@ -33,8 +33,8 @@ class GnomeGlobalShortcutBackend : public GlobalShortcutBackend {
explicit GnomeGlobalShortcutBackend(GlobalShortcuts* parent);

static const char* kGsdService;
static const char* kGsdService2;
static const char* kGsdPath;
static const char* kGsdInterface;

protected:
bool RegisterInNewThread() const { return true; }

0 comments on commit 681f986

Please sign in to comment.