Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changes/fix-macos-zoom-detection-logic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"tao": patch
---
Remove synchronous styleMask mutations in is_zoomed on macOS
27 changes: 15 additions & 12 deletions src/platform_impl/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -976,22 +976,25 @@ impl UnownedWindow {
pub(crate) fn is_zoomed(&self) -> bool {
// because `isZoomed` doesn't work if the window's borderless,
// we make it resizable temporalily.
let curr_mask = unsafe { self.ns_window.styleMask() };
unsafe {
let curr_mask = self.ns_window.styleMask();

let required = NSWindowStyleMask::Titled | NSWindowStyleMask::Resizable;
let needs_temp_mask = !curr_mask.contains(required);
if needs_temp_mask {
self.set_style_mask_sync(required);
}
let required = NSWindowStyleMask::Titled | NSWindowStyleMask::Resizable;
if curr_mask.contains(required) {
return self.ns_window.isZoomed();
}

let is_zoomed: bool = unsafe { self.ns_window.isZoomed() };
if let Some(screen) = self.ns_window.screen() {
let frame = self.ns_window.frame();
let visible_frame = screen.visibleFrame();

// Roll back temp styles
if needs_temp_mask {
self.set_style_mask_sync(curr_mask);
}
return (frame.size.width - visible_frame.size.width).abs() < 1.0
&& (frame.size.height - visible_frame.size.height).abs() < 1.0;
}

is_zoomed
// Fallback to original `isZoomed` check
self.ns_window.isZoomed()
}
}

fn saved_style(&self, shared_state: &mut SharedState) -> NSWindowStyleMask {
Expand Down
Loading