diff --git a/ksmserver/CMakeLists.txt b/ksmserver/CMakeLists.txt --- a/ksmserver/CMakeLists.txt +++ b/ksmserver/CMakeLists.txt @@ -66,6 +66,7 @@ PW::KWorkspace KF5::XmlGui KF5::GlobalAccel + KF5::I18n KF5::KIOCore KF5::KIOWidgets ${X11_LIBRARIES} @@ -75,8 +76,10 @@ Qt5::Quick KF5::Declarative KF5::DBusAddons + KF5::Notifications KF5::Package - KF5::KDELibs4Support # Solid/PowerManagement + KF5::Solid # Solid::Power + KF5::WindowSystem ${PHONON_LIBRARIES} Qt5::Concurrent ) diff --git a/ksmserver/logout.cpp b/ksmserver/logout.cpp --- a/ksmserver/logout.cpp +++ b/ksmserver/logout.cpp @@ -76,7 +76,7 @@ #include "global.h" #include "client.h" -#include +#include #include "logoutprompt_interface.h" #include "shutdown_interface.h" @@ -185,8 +185,11 @@ state = Shutdown; // If the logout was confirmed, let's start a powermanagement inhibition. - // We store the cookie so we can interrupt it if the logout will be canceled - inhibitCookie = Solid::PowerManagement::beginSuppressingSleep(QStringLiteral("Shutting down system")); + // If the logout is canceled, the job is deleted and the inhibition is released. + inhibitionJob = Solid::Power::inhibit(Solid::Power::InhibitionType::Sleep, QStringLiteral("Shutting down system"), this); + if (inhibitionJob) { + inhibitionJob->start(); + } // shall we save the session on logout? KConfigGroup cg(KSharedConfig::openConfig(), "General"); @@ -393,7 +396,8 @@ clientsToSave.clear(); emit subSessionCloseCanceled(); } else { - Solid::PowerManagement::stopSuppressingSleep(inhibitCookie); + delete inhibitionJob; + inhibitionJob = nullptr; qCDebug(KSMSERVER) << "Client " << c->program() << " (" << c->clientId() << ") canceled shutdown."; KNotification::event( QStringLiteral( "cancellogout" ), i18n( "Logout canceled by '%1'", c->program()), diff --git a/ksmserver/server.h b/ksmserver/server.h --- a/ksmserver/server.h +++ b/ksmserver/server.h @@ -60,6 +60,10 @@ class KSMConnection; class KSMClient; +namespace Solid +{ + class InhibitionJob; +} // namespace Solid enum SMType { SM_ERROR, SM_WMCOMMAND, SM_WMSAVEYOURSELF }; struct SMData @@ -245,9 +249,7 @@ WindowMap legacyWindows; - - int inhibitCookie; - + Solid::InhibitionJob* inhibitionJob = nullptr; //subSession stuff QList clientsToKill;