Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
gpui: Fix transparent titlebar in fullscreen mode on macOS (#26403)
Smit Barmase6cfc4dc857b3
diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rsindex ba5011ef160..382ae6f7a77 100644--- a/crates/gpui/src/platform/mac/window.rs+++ b/crates/gpui/src/platform/mac/window.rs@@ -268,6 +268,10 @@ unsafe fn build_window_class(name: &'static str, superclass: &Class) -> *const Csel!(windowWillEnterFullScreen:),window_will_enter_fullscreen as extern "C" fn(&Object, Sel, id),);+ decl.add_method(+ sel!(windowWillExitFullScreen:),+ window_will_exit_fullscreen as extern "C" fn(&Object, Sel, id),+ );decl.add_method(sel!(windowDidMove:),window_did_move as extern "C" fn(&Object, Sel, id),@@ -334,6 +338,7 @@ struct MacWindowState {last_key_equivalent: Option<KeyDownEvent>,synthetic_drag_counter: usize,traffic_light_position: Option<Point<Pixels>>,+ transparent_titlebar: bool,previous_modifiers_changed_event: Option<PlatformInput>,keystroke_for_do_command: Option<Keystroke>,do_command_handled: Option<bool>,@@ -613,6 +618,9 @@ impl MacWindow {traffic_light_position: titlebar.as_ref().and_then(|titlebar| titlebar.traffic_light_position),+ transparent_titlebar: titlebar+ .as_ref()+ .map_or(true, |titlebar| titlebar.appears_transparent),previous_modifiers_changed_event: None,keystroke_for_do_command: None,do_command_handled: None,@@ -1490,6 +1498,19 @@ extern "C" fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) {let window_state = unsafe { get_window_state(this) };let mut lock = window_state.as_ref().lock();lock.fullscreen_restore_bounds = lock.bounds();+ unsafe {+ lock.native_window.setTitlebarAppearsTransparent_(NO);+ }+}++extern "C" fn window_will_exit_fullscreen(this: &Object, _: Sel, _: id) {+ let window_state = unsafe { get_window_state(this) };+ let mut lock = window_state.as_ref().lock();+ if lock.transparent_titlebar {+ unsafe {+ lock.native_window.setTitlebarAppearsTransparent_(YES);+ }+ }}extern "C" fn window_did_move(this: &Object, _: Sel, _: id) {