支持deepin dde
This commit is contained in:
parent
fa4514d4eb
commit
03c763431a
|
|
@ -148,6 +148,7 @@ void MainWindow::onScreenLocked()
|
||||||
// 停止绘制
|
// 停止绘制
|
||||||
if (m_customWidget) {
|
if (m_customWidget) {
|
||||||
m_customWidget->setPaintingEnabled(false);
|
m_customWidget->setPaintingEnabled(false);
|
||||||
|
m_customWidget->resetFrameCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatusDisplay();
|
updateStatusDisplay();
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ bool ScreenLockDetector::initialize()
|
||||||
// 尝试连接到不同的DBus接口
|
// 尝试连接到不同的DBus接口
|
||||||
bool deepinOk = connectToDeepinDDE();
|
bool deepinOk = connectToDeepinDDE();
|
||||||
bool gnomeOk = connectToGnomeScreenSaver();
|
bool gnomeOk = connectToGnomeScreenSaver();
|
||||||
bool loginOk = connectToLoginManager();
|
//bool loginOk = connectToLoginManager();
|
||||||
|
bool loginOk = false;
|
||||||
|
|
||||||
if (!deepinOk && !gnomeOk && !loginOk) {
|
if (!deepinOk && !gnomeOk && !loginOk) {
|
||||||
qWarning() << "Failed to connect to any screen lock detection service";
|
qWarning() << "Failed to connect to any screen lock detection service";
|
||||||
|
|
@ -277,15 +278,10 @@ bool ScreenLockDetector::connectToDeepinDDE()
|
||||||
|
|
||||||
QList<DeepinService> services = {
|
QList<DeepinService> services = {
|
||||||
// Deepin 20/23 主要接口
|
// 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", "Visible", "Visible"},
|
||||||
{"com.deepin.dde.lockFront", "/com/deepin/dde/lockFront", "com.deepin.dde.lockFront", "Lock", "Unlock"},
|
|
||||||
|
|
||||||
// 备用接口
|
// 备用接口
|
||||||
{"com.deepin.ScreenSaver", "/com/deepin/ScreenSaver", "com.deepin.ScreenSaver", "ActiveChanged", "ActiveChanged"},
|
{"com.deepin.daemon.ScreenSaver", "/com/deepin/daemon/ScreenSaver", "com.deepin.daemon.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"},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const auto& svc : services) {
|
for (const auto& svc : services) {
|
||||||
|
|
@ -309,31 +305,21 @@ bool ScreenLockDetector::connectToDeepinDDE()
|
||||||
qDebug() << " Interface is valid, connecting signals...";
|
qDebug() << " Interface is valid, connecting signals...";
|
||||||
|
|
||||||
// 尝试连接锁屏信号
|
// 尝试连接锁屏信号
|
||||||
bool lockedConnected = QDBusConnection::sessionBus().connect(
|
bool visibleConnected = QDBusConnection::sessionBus().connect(
|
||||||
svc.service,
|
svc.service,
|
||||||
svc.path,
|
svc.path,
|
||||||
svc.interface,
|
svc.interface,
|
||||||
svc.lockSignal,
|
svc.lockSignal,
|
||||||
this,
|
this,
|
||||||
SLOT(onSessionLocked())
|
SLOT(onLockFrontVisible(bool))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
qDebug() << " Visible signal (" << svc.lockSignal << ") connected:" << visibleConnected;
|
||||||
|
|
||||||
bool unlockedConnected = QDBusConnection::sessionBus().connect(
|
if (visibleConnected) {
|
||||||
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) {
|
|
||||||
m_deepinConnected = true;
|
m_deepinConnected = true;
|
||||||
qDebug() << "Successfully connected to Deepin DDE via" << svc.service;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,6 +402,15 @@ void ScreenLockDetector::onScreenSaverActiveChanged(bool active)
|
||||||
setLockState(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()
|
void ScreenLockDetector::onSessionLocked()
|
||||||
{
|
{
|
||||||
qDebug() << "##################################################";
|
qDebug() << "##################################################";
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,12 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void onScreenSaverActiveChanged(bool active);
|
void onScreenSaverActiveChanged(bool active);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief 处理DEEPIN屏幕保护程序的DBus信号
|
||||||
|
* @param active 屏幕保护程序是否激活
|
||||||
|
*/
|
||||||
|
void onLockFrontVisible(bool visible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 处理登录管理器的会话锁定信号
|
* @brief 处理登录管理器的会话锁定信号
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue