[feat] add macOS privacy screen and keep remote sessions running

This commit is contained in:
kunkundi
2026-09-13 00:38:40 +08:00
parent 23bf2ff8b8
commit a6e325f190
38 changed files with 1161 additions and 1046 deletions
+9 -10
View File
@@ -7,14 +7,12 @@
#ifndef _PRIVACY_BACKEND_H_
#define _PRIVACY_BACKEND_H_
#include <cstdint>
#include <memory>
#include <string>
namespace crossdesk {
struct PrivacyScreenText {
std::string verification = "Privacy screen verification";
std::string unlock_hint = "To turn off the privacy screen, press";
};
@@ -27,12 +25,13 @@ struct PrivacyCapabilities {
struct PrivacyHealth {
std::string failure;
bool emergency_exit = false;
bool ready = true;
};
// Lifecycle, message pumping and native resource operations run on the
// controller's message thread. Const metadata queries are serialized with
// those operations by the controller mutex and must not call native UI APIs.
// No platform backend is installed on macOS/Linux yet.
// AppKit work is queued to the main thread without waiting under this mutex.
class PrivacyBackend {
public:
virtual ~PrivacyBackend() = default;
@@ -41,23 +40,23 @@ class PrivacyBackend {
std::string& error) = 0;
virtual void Recover() = 0;
virtual bool IsRecovered() const = 0;
virtual PrivacyHealth Poll(bool force_check = false) = 0;
virtual bool RecoveryPending() const { return false; }
virtual PrivacyHealth Poll() = 0;
// Wait on both native window messages and controller commands.
// Wake is the only backend operation callable from another thread.
virtual void WaitForEvents(unsigned timeout_ms) = 0;
virtual void Wake() = 0;
virtual bool PaintChallenge(uint32_t value, const std::string& title,
std::string& error) = 0;
// Remove only the temporary capture probes, keeping all privacy covers up.
// The controller drains queued probe frames before admitting clean video.
virtual bool ClearChallenges(std::string& error) = 0;
virtual bool HasMonitor(int left, int top, int width, int height) const = 0;
};
#ifdef _WIN32
std::unique_ptr<PrivacyBackend> CreateWindowsPrivacyBackend();
bool IsWindowsPrivacyDesktopAvailable();
#endif
#ifdef __APPLE__
std::unique_ptr<PrivacyBackend> CreateMacPrivacyBackend();
// Flush queued AppKit cleanup after joining the controller at app shutdown.
void FlushMacPrivacyTasks();
#endif
} // namespace crossdesk