Fix global shortcuts using GSD D-Bus backend (#6251)
This commit is contained in:
parent
35386a1af8
commit
681f986f0f
@ -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; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user