Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Fix `start_display_link` leading to resource leak on hidden windows (#11289)

Matthias Grandl4024b9ac4d63
diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs
index 86d01ba2dc1..66bb6bd40f9 100644
--- a/crates/gpui/src/platform/mac/window.rs
+++ b/crates/gpui/src/platform/mac/window.rs
@@ -415,6 +415,15 @@ impl MacWindowState {
fn start_display_link(&mut self) {
self.stop_display_link();
+ unsafe {
+ if !self
+ .native_window
+ .occlusionState()
+ .contains(NSWindowOcclusionState::NSWindowOcclusionStateVisible)
+ {
+ return;
+ }
+ }
let display_id = unsafe { display_id_for_screen(self.native_window.screen()) };
if let Some(mut display_link) =
DisplayLink::new(display_id, self.native_view.as_ptr() as *mut c_void, step).log_err()