diff --git a/src/plugin-qt/power/session/misc/dbus/org.deepin.dde.Power1.service b/src/plugin-qt/power/session/misc/dbus/org.deepin.dde.Power1.service index 55ca94f7..7fe8877b 100644 --- a/src/plugin-qt/power/session/misc/dbus/org.deepin.dde.Power1.service +++ b/src/plugin-qt/power/session/misc/dbus/org.deepin.dde.Power1.service @@ -1,4 +1,4 @@ [D-BUS Service] Name=org.deepin.dde.Power1 Exec=/usr/bin/deepin-service-manager -n org.deepin.dde.Power1 -SystemdService=org.deepin.dde.Power1.service +SystemdService=deepin-service-plugin@org.deepin.dde.Power1.service diff --git a/src/plugin-qt/power/session/misc/org.deepin.dde.Power1.service b/src/plugin-qt/power/session/misc/org.deepin.dde.Power1.service deleted file mode 100644 index 46125c50..00000000 --- a/src/plugin-qt/power/session/misc/org.deepin.dde.Power1.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=org.deepin.dde.Power1 (Session) -RefuseManualStart=no -RefuseManualStop=no - -[Service] -Type=dbus -BusName=org.deepin.dde.Power1 -ExecStart=/usr/bin/deepin-service-manager -n org.deepin.dde.Power1 -Restart=on-failure -Slice=session.slice diff --git a/src/plugin-qt/power/session/sessiondbusproxy.cpp b/src/plugin-qt/power/session/sessiondbusproxy.cpp index 0713c024..e7e233e8 100644 --- a/src/plugin-qt/power/session/sessiondbusproxy.cpp +++ b/src/plugin-qt/power/session/sessiondbusproxy.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,12 @@ namespace { constexpr auto kAmbientBrightnessService = "org.deepin.dde.AmbientBrightness1"; constexpr auto kAmbientBrightnessPath = "/org/deepin/dde/AmbientBrightness1"; constexpr auto kAmbientBrightnessInterface = "org.deepin.dde.AmbientBrightness1"; + +void asyncShutdownFrontCall(const QString &method) +{ + QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall( + kShutdownFront, kShutdownPath, kShutdownFront, method)); +} } SessionDBusProxy::SessionDBusProxy(QObject *parent) @@ -31,18 +38,9 @@ SessionDBusProxy::SessionDBusProxy(QObject *parent) , m_sessionManagerInter(new DDBusInterface( kSessionManager, kSessionPath, kSessionManager, QDBusConnection::sessionBus(), this)) - , m_shutdownFrontInter(new DDBusInterface( - kShutdownFront, kShutdownPath, kShutdownFront, - QDBusConnection::sessionBus(), this)) , m_login1Inter(new DDBusInterface( kLogin1Service, kLogin1Path, kLogin1Manager, QDBusConnection::systemBus(), this)) - , m_lockFrontInter(new DDBusInterface( - kLockFront, kLockFrontPath, kLockFront, - QDBusConnection::sessionBus(), this)) - , m_blackScreenInter(new DDBusInterface( - kBlackScreen, kBlackScreenPath, kBlackScreen, - QDBusConnection::sessionBus(), this)) , m_displayInter(new DDBusInterface( kDisplay, kDisplayPath, kDisplay, QDBusConnection::sessionBus(), nullptr)) @@ -322,22 +320,31 @@ bool SessionDBusProxy::canHibernate() void SessionDBusProxy::requestSuspendByFront() { - m_shutdownFrontInter->asyncCall("Suspend"); + // Raw messages only: a DDBusInterface call resolves the remote meta object + // with a blocking Introspect, which deadlocks while the front-end is busy. + asyncShutdownFrontCall(QStringLiteral("Suspend")); } void SessionDBusProxy::requestHibernateByFront() { - m_shutdownFrontInter->asyncCall("Hibernate"); + asyncShutdownFrontCall(QStringLiteral("Hibernate")); } void SessionDBusProxy::requestShutdownByFront() { - m_shutdownFrontInter->asyncCall("Shutdown"); + asyncShutdownFrontCall(QStringLiteral("Shutdown")); } void SessionDBusProxy::showLockAuth(bool autoStart) { - m_lockFrontInter->call("ShowAuth", autoStart); + // Keep the synchronous barrier, but never wait for the front-end's own + // blocking call to finish: one second is enough to deliver ShowAuth. + QDBusMessage msg = QDBusMessage::createMethodCall( + kLockFront, kLockFrontPath, kLockFront, QStringLiteral("ShowAuth")); + msg << autoStart; + const QDBusMessage reply = QDBusConnection::sessionBus().call(msg, QDBus::Block, 1000); + if (reply.type() == QDBusMessage::ErrorMessage) + qWarning("[Proxy] ShowAuth(%d) failed: %s", autoStart, qPrintable(reply.errorMessage())); } void SessionDBusProxy::lockSession(const QString &sessionId) @@ -369,7 +376,8 @@ QDBusMessage SessionDBusProxy::listSessions() const void SessionDBusProxy::setBlackScreenActive(bool active) { - m_blackScreenInter->asyncCall("setActive", active); + QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall( + kBlackScreen, kBlackScreenPath, kBlackScreen, QStringLiteral("setActive")) << active); QDBusInterface kwin(QStringLiteral("org.kde.KWin"), QStringLiteral("/BlackScreen"), QStringLiteral("org.kde.kwin.BlackScreen"), QDBusConnection::sessionBus()); diff --git a/src/plugin-qt/power/session/sessiondbusproxy.h b/src/plugin-qt/power/session/sessiondbusproxy.h index a8e245b9..810afd19 100644 --- a/src/plugin-qt/power/session/sessiondbusproxy.h +++ b/src/plugin-qt/power/session/sessiondbusproxy.h @@ -151,10 +151,7 @@ private Q_SLOTS: DDBusInterface *m_powerInter; DDBusInterface *m_sessionManagerInter; - DDBusInterface *m_shutdownFrontInter; DDBusInterface *m_login1Inter; - DDBusInterface *m_lockFrontInter; - DDBusInterface *m_blackScreenInter; DDBusInterface *m_displayInter; DDBusInterface *m_notificationsInter; DDBusInterface *m_sessionWatcherInter;