From 0a66f3e50eb956a90929d802a7bfd4487566e3e1 Mon Sep 17 00:00:00 2001 From: H-Chris233 Date: Sat, 30 May 2026 15:14:08 +0800 Subject: [PATCH 1/2] fix(macos): show capsule in fullscreen Spaces --- .../app/scripts/macos-capsule-spaces-contract.test.mjs | 6 ++++++ openless-all/app/src-tauri/src/coordinator.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs b/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs index 0d48305a..317d70d3 100644 --- a/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs +++ b/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs @@ -26,6 +26,12 @@ assertMatch( 'macOS capsule should join all Spaces before showing without activation', ); +assertMatch( + macosNoActivateFunction, + /FullScreenAuxiliary[\s\S]*?setCollectionBehavior[\s\S]*?orderFrontRegardless/, + 'macOS capsule should join fullscreen Spaces as an auxiliary window before showing without activation', +); + for (const forbidden of ['window.show()', 'set_focus', 'NSApp.activate', 'makeKeyAndOrderFront']) { if (executableMacosNoActivateFunction.includes(forbidden)) { throw new Error(`macOS capsule no-activate path must not call ${forbidden}`); diff --git a/openless-all/app/src-tauri/src/coordinator.rs b/openless-all/app/src-tauri/src/coordinator.rs index b7869133..82671cb4 100644 --- a/openless-all/app/src-tauri/src/coordinator.rs +++ b/openless-all/app/src-tauri/src/coordinator.rs @@ -4489,6 +4489,7 @@ fn show_capsule_window_no_activate( ) -> bool { use objc2::msg_send; use objc2::runtime::AnyObject; + use objc2_app_kit::NSWindowCollectionBehavior; let Ok(handle) = window.ns_window() else { return false; @@ -4507,6 +4508,11 @@ fn show_capsule_window_no_activate( } unsafe { + let behavior: NSWindowCollectionBehavior = msg_send![ns_window, collectionBehavior]; + let behavior = behavior + | NSWindowCollectionBehavior::CanJoinAllSpaces + | NSWindowCollectionBehavior::FullScreenAuxiliary; + let _: () = msg_send![ns_window, setCollectionBehavior: behavior]; let _: () = msg_send![ns_window, orderFrontRegardless]; } true From a5970f8c1219acc558223e38e1071409e1dc7bb5 Mon Sep 17 00:00:00 2001 From: H-Chris233 Date: Sun, 31 May 2026 11:29:43 +0800 Subject: [PATCH 2/2] fix(macos): avoid gated AppKit collection type --- .../app/scripts/macos-capsule-spaces-contract.test.mjs | 2 +- openless-all/app/src-tauri/src/coordinator.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs b/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs index 317d70d3..f83684b6 100644 --- a/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs +++ b/openless-all/app/scripts/macos-capsule-spaces-contract.test.mjs @@ -28,7 +28,7 @@ assertMatch( assertMatch( macosNoActivateFunction, - /FullScreenAuxiliary[\s\S]*?setCollectionBehavior[\s\S]*?orderFrontRegardless/, + /FULL_SCREEN_AUXILIARY[\s\S]*?1 << 8[\s\S]*?setCollectionBehavior[\s\S]*?orderFrontRegardless/, 'macOS capsule should join fullscreen Spaces as an auxiliary window before showing without activation', ); diff --git a/openless-all/app/src-tauri/src/coordinator.rs b/openless-all/app/src-tauri/src/coordinator.rs index 82671cb4..abb01a28 100644 --- a/openless-all/app/src-tauri/src/coordinator.rs +++ b/openless-all/app/src-tauri/src/coordinator.rs @@ -4489,7 +4489,6 @@ fn show_capsule_window_no_activate( ) -> bool { use objc2::msg_send; use objc2::runtime::AnyObject; - use objc2_app_kit::NSWindowCollectionBehavior; let Ok(handle) = window.ns_window() else { return false; @@ -4508,10 +4507,12 @@ fn show_capsule_window_no_activate( } unsafe { - let behavior: NSWindowCollectionBehavior = msg_send![ns_window, collectionBehavior]; + const NS_WINDOW_COLLECTION_BEHAVIOR_CAN_JOIN_ALL_SPACES: usize = 1 << 0; + const NS_WINDOW_COLLECTION_BEHAVIOR_FULL_SCREEN_AUXILIARY: usize = 1 << 8; + let behavior: usize = msg_send![ns_window, collectionBehavior]; let behavior = behavior - | NSWindowCollectionBehavior::CanJoinAllSpaces - | NSWindowCollectionBehavior::FullScreenAuxiliary; + | NS_WINDOW_COLLECTION_BEHAVIOR_CAN_JOIN_ALL_SPACES + | NS_WINDOW_COLLECTION_BEHAVIOR_FULL_SCREEN_AUXILIARY; let _: () = msg_send![ns_window, setCollectionBehavior: behavior]; let _: () = msg_send![ns_window, orderFrontRegardless]; }