增加支持KylinOS

This commit is contained in:
ubuntu1804 2025-11-10 10:34:04 +08:00
parent 471b4c7b3b
commit ac16f7d054
3 changed files with 47 additions and 90 deletions

View File

@ -213,7 +213,7 @@ export LD_LIBRARY_PATH=$HOME/sdk/qt-5.15.2/lib:$LD_LIBRARY_PATH
Service: com.deepin.dde.lockFront
Path: /com/deepin/dde/lockFront
Interface: com.deepin.dde.lockFront
Signals: Locked(), Unlocked()
Signals: Visible(bool)
```
2. **GNOME ScreenSaver 接口**
@ -224,12 +224,12 @@ export LD_LIBRARY_PATH=$HOME/sdk/qt-5.15.2/lib:$LD_LIBRARY_PATH
Signal: ActiveChanged(bool)
```
3. **systemd-logind 接口**
3. **KylinOS UKUI接口**
```
Service: org.freedesktop.login1
Path: /org/freedesktop/login1/session/auto
Interface: org.freedesktop.login1.Session
Signals: Lock(), Unlock()
Service: org.ukui.ScreenSaver
Path: /
Interface: org.ukui.ScreenSaver
Signals: lock(), unlock()
```
### macOS: 分布式通知中心

View File

@ -101,7 +101,7 @@ bool ScreenLockDetector::initialize()
// 尝试连接到不同的DBus接口
bool deepinOk = connectToDeepinDDE();
bool gnomeOk = connectToGnomeScreenSaver();
bool loginOk = connectToLoginManager();
bool loginOk = connectToUkuiManager();
if (!deepinOk && !gnomeOk && !loginOk) {
qWarning() << "Failed to connect to any screen lock detection service";
@ -195,47 +195,37 @@ bool ScreenLockDetector::connectToGnomeScreenSaver()
return true;
}
bool ScreenLockDetector::connectToLoginManager()
bool ScreenLockDetector::connectToUkuiManager()
{
qDebug() << "\n--- Connecting to Login Manager (systemd-logind) ---";
qDebug() << "\n--- Connecting to ukui ScreenSaver ---";
// 首先获取当前会话的路径
QString sessionPath = getCurrentSessionPath();
if (sessionPath.isEmpty()) {
qWarning() << "Could not determine current session path";
qWarning() << "Will try to connect to generic session signals";
} else {
qDebug() << "Current session path:" << sessionPath;
}
// 方法1: 连接到特定会话路径(如果获取到了)
if (!sessionPath.isEmpty()) {
QString sessionPath = "/";
m_loginInterface = new QDBusInterface(
"org.freedesktop.login1",
"org.ukui.ScreenSaver",
sessionPath,
"org.freedesktop.login1.Session",
"org.ukui.ScreenSaver",
QDBusConnection::systemBus(),
this
);
if (m_loginInterface->isValid()) {
qDebug() << "Login Manager interface is valid for session:" << sessionPath;
qDebug() << "ukui ScreenSaver interface is valid for session:" << sessionPath;
// 连接Lock和Unlock信号到特定会话
bool lockConnected = QDBusConnection::systemBus().connect(
"org.freedesktop.login1",
"org.ukui.ScreenSaver",
sessionPath,
"org.freedesktop.login1.Session",
"Lock",
"org.ukui.ScreenSaver",
"lock",
this,
SLOT(onSessionLocked())
);
bool unlockConnected = QDBusConnection::systemBus().connect(
"org.freedesktop.login1",
"org.ukui.ScreenSaver",
sessionPath,
"org.freedesktop.login1.Session",
"Unlock",
"org.ukui.ScreenSaver",
"unlock",
this,
SLOT(onSessionUnlocked())
);
@ -248,44 +238,11 @@ bool ScreenLockDetector::connectToLoginManager()
qDebug() << "Successfully connected to Login Manager via session path";
return true;
}
} else {
qDebug() << "Login Manager interface not valid:" << m_loginInterface->lastError().message();
delete m_loginInterface;
m_loginInterface = nullptr;
}
}
// 方法2: 监听所有会话的Lock/Unlock信号不指定具体路径
qDebug() << "Attempting to connect to all login1 Session signals...";
bool lockConnected = QDBusConnection::systemBus().connect(
"org.freedesktop.login1",
"", // 空路径表示监听所有对象
"org.freedesktop.login1.Session",
"Lock",
this,
SLOT(onSessionLocked())
);
bool unlockConnected = QDBusConnection::systemBus().connect(
"org.freedesktop.login1",
"", // 空路径表示监听所有对象
"org.freedesktop.login1.Session",
"Unlock",
this,
SLOT(onSessionUnlocked())
);
qDebug() << "Generic Lock signal connected:" << lockConnected;
qDebug() << "Generic Unlock signal connected:" << unlockConnected;
if (lockConnected || unlockConnected) {
m_loginConnected = true;
qDebug() << "Successfully connected to Login Manager via generic signals";
return true;
}
qWarning() << "Failed to connect to Login Manager signals";
delete m_loginInterface;
m_loginInterface = nullptr;
return false;
}

View File

@ -108,10 +108,10 @@ private:
bool connectToGnomeScreenSaver();
/**
* @brief DBus接口
* @brief KylinOS的DBus接口
* @return true
*/
bool connectToLoginManager();
bool connectToUkuiManager();
/**
* @brief Deepin DDE的DBus接口