diff --git a/src/common/commondefine.h b/src/common/commondefine.h index 8497b4ee..8d882b09 100644 --- a/src/common/commondefine.h +++ b/src/common/commondefine.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -41,5 +41,10 @@ const static QString ShutdownFront1Service = QStringLiteral("org.deepin.dde.Shut const static QString ShutdownFront1Path = QStringLiteral("/org/deepin/dde/ShutdownFront1"); const static QString ShutdownFront1Interface = QStringLiteral("org.deepin.dde.ShutdownFront1"); +// SessionManager1 +const static QString SessionManager1Service = QStringLiteral("org.deepin.dde.SessionManager1"); +const static QString SessionManager1Path = QStringLiteral("/org/deepin/dde/SessionManager1"); +const static QString SessionManager1Interface = QStringLiteral("org.deepin.dde.SessionManager1"); + const static QString PropertiesInterface = QStringLiteral("org.freedesktop.DBus.Properties"); const static QString PropertiesChanged = QStringLiteral("PropertiesChanged"); diff --git a/src/common/dbus/updatedbusproxy.cpp b/src/common/dbus/updatedbusproxy.cpp index f6716b78..e13e19f2 100644 --- a/src/common/dbus/updatedbusproxy.cpp +++ b/src/common/dbus/updatedbusproxy.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include "common/commondefine.h" @@ -39,6 +40,8 @@ UpdateDBusProxy::UpdateDBusProxy(QObject *parent) LockService, LockPath, LockInterface, QDBusConnection::systemBus(), this)) , m_shutdownFrontInter(new DDBusInterface( ShutdownFront1Service, ShutdownFront1Path, ShutdownFront1Interface, QDBusConnection::sessionBus(), this)) + , m_sessionManagerInter(new DDBusInterface( + SessionManager1Service, SessionManager1Path, SessionManager1Interface, QDBusConnection::sessionBus(), this)) , m_interWatcher(new QDBusServiceWatcher(UpdaterService, QDBusConnection::systemBus())) { @@ -553,15 +556,27 @@ QString UpdateDBusProxy::CurrentUser() void UpdateDBusProxy::Restart() { qCInfo(logCommon) << "Calling system restart"; - m_shutdownFrontInter->asyncCall(QStringLiteral("Restart")); + if (Dtk::Gui::DGuiApplicationHelper::testAttribute(Dtk::Gui::DGuiApplicationHelper::IsWaylandPlatform)) { + m_sessionManagerInter->asyncCall(QStringLiteral("RequestReboot")); + } else { + m_shutdownFrontInter->asyncCall(QStringLiteral("Restart")); + } } void UpdateDBusProxy::UpdateAndReboot() { qCInfo(logCommon) << "Calling update and reboot"; - m_shutdownFrontInter->asyncCall(QStringLiteral("UpdateAndReboot")); + if (Dtk::Gui::DGuiApplicationHelper::testAttribute(Dtk::Gui::DGuiApplicationHelper::IsWaylandPlatform)) { + m_sessionManagerInter->asyncCall(QStringLiteral("RequestReboot")); + } else { + m_shutdownFrontInter->asyncCall(QStringLiteral("UpdateAndReboot")); + } } void UpdateDBusProxy::UpdateAndShutdown() { qCInfo(logCommon) << "Calling update and shutdown"; - m_shutdownFrontInter->asyncCall(QStringLiteral("UpdateAndShutdown")); -} \ No newline at end of file + if (Dtk::Gui::DGuiApplicationHelper::testAttribute(Dtk::Gui::DGuiApplicationHelper::IsWaylandPlatform)) { + m_sessionManagerInter->asyncCall(QStringLiteral("RequestShutdown")); + } else { + m_shutdownFrontInter->asyncCall(QStringLiteral("UpdateAndShutdown")); + } +} diff --git a/src/common/dbus/updatedbusproxy.h b/src/common/dbus/updatedbusproxy.h index 0f347fc3..3097c2d2 100644 --- a/src/common/dbus/updatedbusproxy.h +++ b/src/common/dbus/updatedbusproxy.h @@ -188,6 +188,7 @@ class UpdateDBusProxy : public QObject DDBusInterface *m_login1Inter; DDBusInterface *m_lockServiceInter; DDBusInterface *m_shutdownFrontInter; + DDBusInterface *m_sessionManagerInter; QDBusServiceWatcher *m_interWatcher; }; diff --git a/src/dock-update-plugin/pluginupdateplugin.cpp b/src/dock-update-plugin/pluginupdateplugin.cpp index cc33a633..e7d277a0 100644 --- a/src/dock-update-plugin/pluginupdateplugin.cpp +++ b/src/dock-update-plugin/pluginupdateplugin.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2025-2026 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2025 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -189,12 +189,21 @@ void PluginUpdatePlugin::invokedMenuItem(const QString &itemKey, const QString & .call(); } else if (menuId == MENU_RESTART) { // 重启系统 - DDBusSender() - .service("org.deepin.dde.ShutdownFront1") - .interface("org.deepin.dde.ShutdownFront1") - .path("/org/deepin/dde/ShutdownFront1") - .method("Restart") - .call(); + if (Dtk::Gui::DGuiApplicationHelper::testAttribute(Dtk::Gui::DGuiApplicationHelper::IsWaylandPlatform)) { + DDBusSender() + .service("org.deepin.dde.SessionManager1") + .interface("org.deepin.dde.SessionManager1") + .path("/org/deepin/dde/SessionManager1") + .method("RequestReboot") + .call(); + } else { + DDBusSender() + .service("org.deepin.dde.ShutdownFront1") + .interface("org.deepin.dde.ShutdownFront1") + .path("/org/deepin/dde/ShutdownFront1") + .method("Restart") + .call(); + } } }