Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): rerun the occlusion handler after native shows only on macOS 27

Richie McIlroyabfcee0efdc7
diff --git a/apps/desktop-gpui/src/platform.rs b/apps/desktop-gpui/src/platform.rs
index 586db6028..8fd0ed53a 100644
--- a/apps/desktop-gpui/src/platform.rs
+++ b/apps/desktop-gpui/src/platform.rs
@@ -939,15 +939,21 @@ mod mac {
}
}
- /// The shim reports an ordered-out window as hidden, so its link stops;
- /// every native show re-runs the gate rather than trusting AppKit to post
- /// an occlusion change for the window coming back.
fn rerun_occlusion_handler(ns_window: &NSWindow) {
unsafe {
let _: () = objc2::msg_send![ns_window, windowDidChangeOcclusionState: std::ptr::null_mut::<AnyObject>()];
}
}
+ /// Where the shim reports an ordered-out window as hidden (so its link
+ /// stops), every native show re-runs the gate rather than trusting AppKit
+ /// to post an occlusion change for the window coming back.
+ fn rerun_occlusion_handler_after_show(ns_window: &NSWindow) {
+ if super::macos_occlusion::ordered_out_windows_keep_raw_state() {
+ rerun_occlusion_handler(ns_window);
+ }
+ }
+
#[link(name = "CoreGraphics", kind = "framework")]
unsafe extern "C" {
fn CGWindowLevelForKey(key: i32) -> i32;
@@ -1243,7 +1249,7 @@ mod mac {
/// Same task-only rule as every other ordering call here.
pub fn order_front_native(native: &NativeWindow) {
unsafe { native.0.orderFrontRegardless() };
- rerun_occlusion_handler(&native.0);
+ rerun_occlusion_handler_after_show(&native.0);
}
/// The `NSWindow` behind a gpui window.
@@ -1371,7 +1377,7 @@ mod mac {
/// Reverse of [`hide_native`] -- `makeKeyAndOrderFront:`.
pub fn show_native(native: &NativeWindow) {
native.0.makeKeyAndOrderFront(None);
- rerun_occlusion_handler(&native.0);
+ rerun_occlusion_handler_after_show(&native.0);
}
/// Close the window the way the red traffic light does: ask the
@@ -1705,7 +1711,7 @@ mod mac {
pub fn show_window_without_focus(window: &Window) {
if let Some(ns_window) = ns_window(window) {
unsafe { ns_window.orderFrontRegardless() };
- rerun_occlusion_handler(&ns_window);
+ rerun_occlusion_handler_after_show(&ns_window);
}
}
diff --git a/apps/desktop-gpui/src/platform/macos_occlusion.rs b/apps/desktop-gpui/src/platform/macos_occlusion.rs
index 0a4660a0d..0c4405979 100644
--- a/apps/desktop-gpui/src/platform/macos_occlusion.rs
+++ b/apps/desktop-gpui/src/platform/macos_occlusion.rs
@@ -84,7 +84,7 @@ fn reported_state(
}
}
-fn ordered_out_windows_keep_raw_state() -> bool {
+pub(super) fn ordered_out_windows_keep_raw_state() -> bool {
static KEEP_RAW: OnceLock<bool> = OnceLock::new();
*KEEP_RAW.get_or_init(|| macos_major_version().is_some_and(|major| major >= 27))
}