solid: fix screen power management supressesion

this has been broken since before the fork because message was send with
wrong cookie type

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-11-30 05:23:12 +02:00
parent 806b06db55
commit 58f6472d45

View file

@ -136,6 +136,7 @@ bool Solid::PowerManagement::stopSuppressingSleep(int cookie)
int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString& reason)
{
#warning TODO: the return type should be uint
if (globalPowerManager()->saverIface.isValid()) {
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
QLatin1String("/ScreenSaver"),
@ -157,14 +158,18 @@ int Solid::PowerManagement::beginSuppressingScreenPowerManagement(const QString&
bool Solid::PowerManagement::stopSuppressingScreenPowerManagement(int cookie)
{
#warning TODO: the cookie type should be uint
if (globalPowerManager()->saverIface.isValid()) {
if (globalPowerManager()->screensaverCookies.contains(cookie)) {
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.ScreenSaver"),
QLatin1String("/ScreenSaver"),
QLatin1String("org.freedesktop.ScreenSaver"),
QLatin1String("UnInhibit"));
message << cookie;
QDBusConnection::sessionBus().asyncCall(message);
message << uint(cookie);
QDBusReply<void> ssReply = QDBusConnection::sessionBus().call(message);
if (ssReply.isValid()) {
globalPowerManager()->screensaverCookies.removeAll(cookie);
}
}
return true;