支持deepin dde
This commit is contained in:
parent
fa4514d4eb
commit
03c763431a
|
|
@ -148,6 +148,7 @@ void MainWindow::onScreenLocked()
|
|||
// 停止绘制
|
||||
if (m_customWidget) {
|
||||
m_customWidget->setPaintingEnabled(false);
|
||||
m_customWidget->resetFrameCount();
|
||||
}
|
||||
|
||||
updateStatusDisplay();
|
||||
|
|
|
|||
|
|
@ -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<DeepinService> 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))
|
||||
);
|
||||
|
||||
bool unlockedConnected = QDBusConnection::sessionBus().connect(
|
||||
svc.service,
|
||||
svc.path,
|
||||
svc.interface,
|
||||
svc.unlockSignal,
|
||||
this,
|
||||
SLOT(onSessionUnlocked())
|
||||
);
|
||||
qDebug() << " Visible signal (" << svc.lockSignal << ") connected:" << visibleConnected;
|
||||
|
||||
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() << "##################################################";
|
||||
|
|
|
|||
|
|
@ -61,6 +61,12 @@ private slots:
|
|||
*/
|
||||
void onScreenSaverActiveChanged(bool active);
|
||||
|
||||
/**
|
||||
* @brief 处理DEEPIN屏幕保护程序的DBus信号
|
||||
* @param active 屏幕保护程序是否激活
|
||||
*/
|
||||
void onLockFrontVisible(bool visible);
|
||||
|
||||
/**
|
||||
* @brief 处理登录管理器的会话锁定信号
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue