shift-shell/components/mobileshellstate/lockscreendbusclient.cpp
Devin Lin 3b6951bf1e panel: Overlay over lockscreen
Overlay the shell's status panel and quicksettings panel over the lockscreen, instead of rendering a second copy in the lockscreen theme. This will allow us to improve the lockscreen loading speed.

Key changes:
- Overlay quicksettings window and the status bar over the lockscreen when it is shown
- Refactor the top panel's showing logic to be cleaner (as it supports various overlay modes over fullscreen apps already)
- Implement lockscreen support to the status bar and quicksettings panel in the to panel
- Forward quicksettings panel requests for "unlock" over DBus to the lockscreen
- Add "raiselockscreen" QML plugin to easily request a window to be raised over the lockscreen

Notes:
- Now that we are sharing the quicksettings panel from the shell, notifications that are already there will be shown on the lockscreen (compared to right now, where only new notifications would be shown)

Depends on: 
- https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2339
- https://invent.kde.org/plasma/kscreenlocker/-/merge_requests/283
- https://invent.kde.org/plasma/kwin/-/merge_requests/7839

Implements: https://invent.kde.org/plasma/plasma-mobile/-/issues/199

![Screencast_20250612_013325](/uploads/49e9981cb863056b4c0c46a144e5ee7d/Screencast_20250612_013325.webm)
2025-07-02 10:27:33 -04:00

62 lines
2.5 KiB
C++

// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#include "lockscreendbusclient.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusReply>
#include <QTimer>
LockscreenDBusClient::LockscreenDBusClient(QObject *parent)
: QObject{parent}
{
QDBusMessage request = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"),
QStringLiteral("/ScreenSaver"),
QStringLiteral("org.freedesktop.ScreenSaver"),
QStringLiteral("GetActive"));
QDBusConnection::sessionBus().callWithCallback(request, this, SLOT(slotLockscreenActiveChanged(bool)), SLOT(dbusError(QDBusError)));
QDBusConnection::sessionBus().connect(QStringLiteral("org.freedesktop.ScreenSaver"),
QStringLiteral("/ScreenSaver"),
QStringLiteral("org.freedesktop.ScreenSaver"),
QStringLiteral("ActiveChanged"),
this,
SLOT(slotLockscreenActiveChanged(bool)));
}
bool LockscreenDBusClient::lockscreenActive() const
{
return m_lockscreenActive;
}
void LockscreenDBusClient::lockScreen()
{
QDBusMessage request = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.ScreenSaver"),
QStringLiteral("/ScreenSaver"),
QStringLiteral("org.freedesktop.ScreenSaver"),
QStringLiteral("Lock"));
QDBusConnection::sessionBus().call(request);
}
void LockscreenDBusClient::slotLockscreenActiveChanged(bool active)
{
if (active != m_lockscreenActive) {
m_lockscreenActive = active;
Q_EMIT lockscreenActiveChanged();
// we don't want to trigger a lockscreen changing signal for the first property fetch (in constructor),
// since it's just getting the current state
if (m_firstPropertySet) {
m_lockscreenActive ? Q_EMIT lockscreenLocked() : Q_EMIT lockscreenUnlocked();
}
m_firstPropertySet = true;
}
}
void LockscreenDBusClient::dbusError(QDBusError error)
{
qDebug() << "Error fetching lockscreen state using DBus:" << error.message();
}