From 03c763431a9739ee682e96548af6041b17a9346c Mon Sep 17 00:00:00 2001 From: ubuntu1804 Date: Sat, 8 Nov 2025 09:56:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81deepin=20dde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 1 + src/screenlockdetector.cpp | 43 +++++++++++++++++--------------------- src/screenlockdetector.h | 6 ++++++ 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4bc790a..271baf0 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -148,6 +148,7 @@ void MainWindow::onScreenLocked() // 停止绘制 if (m_customWidget) { m_customWidget->setPaintingEnabled(false); + m_customWidget->resetFrameCount(); } updateStatusDisplay(); diff --git a/src/screenlockdetector.cpp b/src/screenlockdetector.cpp index fd97299..fd7e402 100644 --- a/src/screenlockdetector.cpp +++ b/src/screenlockdetector.cpp @@ -48,7 +48,8 @@ bool ScreenLockDetector::initialize() // 尝试连接到不同的DBus接口 bool deepinOk = connectToDeepinDDE(); bool gnomeOk = connectToGnomeScreenSaver(); - bool loginOk = connectToLoginManager(); + //bool loginOk = connectToLoginManager(); + bool loginOk = false; if (!deepinOk && !gnomeOk && !loginOk) { qWarning() << "Failed to connect to any screen lock detection service"; @@ -277,15 +278,10 @@ bool ScreenLockDetector::connectToDeepinDDE() QList services = { // Deepin 20/23 主要接口 - {"com.deepin.dde.lockFront", "/com/deepin/dde/lockFront", "com.deepin.dde.lockFront", "Locked", "Unlocked"}, - {"com.deepin.dde.lockFront", "/com/deepin/dde/lockFront", "com.deepin.dde.lockFront", "Lock", "Unlock"}, + {"com.deepin.dde.lockFront", "/com/deepin/dde/lockFront", "com.deepin.dde.lockFront", "Visible", "Visible"}, // 备用接口 - {"com.deepin.ScreenSaver", "/com/deepin/ScreenSaver", "com.deepin.ScreenSaver", "ActiveChanged", "ActiveChanged"}, - {"com.deepin.SessionManager", "/com/deepin/SessionManager", "com.deepin.SessionManager", "Locked", "Unlocked"}, - - // org.deepin 命名空间 - {"org.deepin.dde.lockFront", "/org/deepin/dde/lockFront", "org.deepin.dde.lockFront", "Locked", "Unlocked"}, + {"com.deepin.daemon.ScreenSaver", "/com/deepin/daemon/ScreenSaver", "com.deepin.daemon.ScreenSaver", "ActiveChanged", "ActiveChanged"}, }; for (const auto& svc : services) { @@ -309,31 +305,21 @@ bool ScreenLockDetector::connectToDeepinDDE() qDebug() << " Interface is valid, connecting signals..."; // 尝试连接锁屏信号 - bool lockedConnected = QDBusConnection::sessionBus().connect( + bool visibleConnected = QDBusConnection::sessionBus().connect( svc.service, svc.path, svc.interface, svc.lockSignal, this, - SLOT(onSessionLocked()) + SLOT(onLockFrontVisible(bool)) ); + + qDebug() << " Visible signal (" << svc.lockSignal << ") connected:" << visibleConnected; - bool unlockedConnected = QDBusConnection::sessionBus().connect( - svc.service, - svc.path, - svc.interface, - svc.unlockSignal, - this, - SLOT(onSessionUnlocked()) - ); - - qDebug() << " Lock signal (" << svc.lockSignal << ") connected:" << lockedConnected; - qDebug() << " Unlock signal (" << svc.unlockSignal << ") connected:" << unlockedConnected; - - if (lockedConnected || unlockedConnected) { + if (visibleConnected) { m_deepinConnected = true; qDebug() << "Successfully connected to Deepin DDE via" << svc.service; - qDebug() << "Listening for signals:" << svc.lockSignal << "and" << svc.unlockSignal; + qDebug() << "Listening for signals:" << svc.lockSignal; return true; } @@ -416,6 +402,15 @@ void ScreenLockDetector::onScreenSaverActiveChanged(bool active) setLockState(active); } +void ScreenLockDetector::onLockFrontVisible(bool visible) +{ + qDebug() << "##################################################"; + qDebug() << "## DEEPIN LockFront Visible signal received"; + qDebug() << "## New state:" << (visible ? "ACTIVE (LOCKED)" : "INACTIVE (UNLOCKED)"); + qDebug() << "##################################################"; + setLockState(visible); +} + void ScreenLockDetector::onSessionLocked() { qDebug() << "##################################################"; diff --git a/src/screenlockdetector.h b/src/screenlockdetector.h index d772fe7..4e59bc8 100644 --- a/src/screenlockdetector.h +++ b/src/screenlockdetector.h @@ -61,6 +61,12 @@ private slots: */ void onScreenSaverActiveChanged(bool active); + /** + * @brief 处理DEEPIN屏幕保护程序的DBus信号 + * @param active 屏幕保护程序是否激活 + */ + void onLockFrontVisible(bool visible); + /** * @brief 处理登录管理器的会话锁定信号 */