[feat] expose system controls and verify remote unlock completion

This commit is contained in:
dijunkun committed 2026-11-06 20:46:11 +08:00
1 parent 6bfcd5cf3d
commit dd4baf2fc4
16 files changed
+222 -15

No files matched your search

@@ -7,11 +7,23 @@
#include "screen_lock.h"
#include <dlfcn.h>
#include <ApplicationServices/ApplicationServices.h>
#include "rd_log.h"
namespace crossdesk {
ScreenLockState QueryScreenLock() {
const auto session = CGSessionCopyCurrentDictionary();
if (!session) return ScreenLockState::unknown;
const auto console = CFDictionaryGetValue(session, kCGSessionOnConsoleKey);
const auto locked = CFDictionaryGetValue(session, CFSTR("CGSSessionScreenIsLocked"));
const auto state = locked == kCFBooleanTrue ? ScreenLockState::locked
: console == kCFBooleanTrue ? ScreenLockState::unlocked : ScreenLockState::unknown;
CFRelease(session);
return state;
}
bool LockScreen() {
// macOS has no public immediate-lock API. Resolve login.framework at
// runtime so an OS without this private entry point fails gracefully.