An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
fix(macos): turn privacy mode off before locking at session end (#16729)
Oleg95cca3f661f6
diff --git a/src/platform/macos.mm b/src/platform/macos.mmindex d4038da8e..ae5a3f088 100644--- a/src/platform/macos.mm+++ b/src/platform/macos.mm@@ -802,6 +802,22 @@ static bool TurnOffPrivacyModeInternal() {}extern "C" bool MacSetPrivacyMode(bool on) {+ if (!on && ![NSThread isMainThread]) {+ {+ std::lock_guard<std::mutex> lock(g_privacyModeMutex);+ if (!g_privacyModeActive) {+ return true;+ }+ }+ // The blackout monitor, the reconfiguration callback and the deferred shutdown lock+ // g_privacyModeMutex on the main thread, so the teardown must not wait for the main+ // queue while holding the mutex. Turn privacy mode off on the main queue instead.+ __block bool result = true;+ dispatch_sync(dispatch_get_main_queue(), ^{+ result = MacSetPrivacyMode(false);+ });+ return result;+ }std::lock_guard<std::mutex> lock(g_privacyModeMutex);if (on) {// Already in privacy modediff --git a/src/privacy_mode/macos.rs b/src/privacy_mode/macos.rsindex e6ea11e49..7a9846286 100644--- a/src/privacy_mode/macos.rs+++ b/src/privacy_mode/macos.rs@@ -79,3 +79,13 @@ impl Drop for PrivacyModeImpl {self.clear();}}++/// Most closes lock before the connection loop turns privacy mode off, and a lock shortcut+/// injected while the tap and the blackout are torn down can be lost (#15875).+pub fn turn_off_before_lock(conn_id: i32) {+ if super::get_privacy_mode_conn_id() == Some(conn_id) {+ if let Some(Err(e)) = super::turn_off_privacy(conn_id, None) {+ hbb_common::log::error!("Failed to turn off privacy mode before locking: {}", e);+ }+ }+}diff --git a/src/server/connection.rs b/src/server/connection.rsindex 83435fc45..4b2eec880 100644--- a/src/server/connection.rs+++ b/src/server/connection.rs@@ -5322,6 +5322,8 @@ impl Connection {&& self.keyboard&& !raii::AuthedConnID::session_reconnected(self.inner.id(), &self.session_key()){+ #[cfg(target_os = "macos")]+ privacy_mode::macos::turn_off_before_lock(self.inner.id());#[cfg(not(any(target_os = "android", target_os = "ios")))]lock_screen().await;}