Skip to content

Commit 6cfc4dc

Browse files
authored
gpui: Fix transparent titlebar in fullscreen mode on macOS (#26403)
Closes #23735 This PR fixes an issue where Zed shows a transparent title bar in fullscreen mode on macOS instead of the default gray one. When switching to fullscreen mode, we change the title bar appearance to opaque. When exiting fullscreen mode, we check the existing `appears_transparent` flag that we pass to gpui to decide whether to change the title bar back to transparent or not. Note: Regardless of the `appears_transparent` flag, gpui should always show an opaque title bar in fullscreen mode to prevent a broken appearance, as macOS always displays the title bar in fullscreen mode upon mouse interaction. https://github.com/user-attachments/assets/211fb185-239b-454e-ac7f-b93b25d33805 Release Notes: - Fixed issue where Zed showed transparent titlebar in fullscreen mode on macOS.
1 parent b9c4868 commit 6cfc4dc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

crates/gpui/src/platform/mac/window.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ unsafe fn build_window_class(name: &'static str, superclass: &Class) -> *const C
268268
sel!(windowWillEnterFullScreen:),
269269
window_will_enter_fullscreen as extern "C" fn(&Object, Sel, id),
270270
);
271+
decl.add_method(
272+
sel!(windowWillExitFullScreen:),
273+
window_will_exit_fullscreen as extern "C" fn(&Object, Sel, id),
274+
);
271275
decl.add_method(
272276
sel!(windowDidMove:),
273277
window_did_move as extern "C" fn(&Object, Sel, id),
@@ -334,6 +338,7 @@ struct MacWindowState {
334338
last_key_equivalent: Option<KeyDownEvent>,
335339
synthetic_drag_counter: usize,
336340
traffic_light_position: Option<Point<Pixels>>,
341+
transparent_titlebar: bool,
337342
previous_modifiers_changed_event: Option<PlatformInput>,
338343
keystroke_for_do_command: Option<Keystroke>,
339344
do_command_handled: Option<bool>,
@@ -613,6 +618,9 @@ impl MacWindow {
613618
traffic_light_position: titlebar
614619
.as_ref()
615620
.and_then(|titlebar| titlebar.traffic_light_position),
621+
transparent_titlebar: titlebar
622+
.as_ref()
623+
.map_or(true, |titlebar| titlebar.appears_transparent),
616624
previous_modifiers_changed_event: None,
617625
keystroke_for_do_command: None,
618626
do_command_handled: None,
@@ -1490,6 +1498,19 @@ extern "C" fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) {
14901498
let window_state = unsafe { get_window_state(this) };
14911499
let mut lock = window_state.as_ref().lock();
14921500
lock.fullscreen_restore_bounds = lock.bounds();
1501+
unsafe {
1502+
lock.native_window.setTitlebarAppearsTransparent_(NO);
1503+
}
1504+
}
1505+
1506+
extern "C" fn window_will_exit_fullscreen(this: &Object, _: Sel, _: id) {
1507+
let window_state = unsafe { get_window_state(this) };
1508+
let mut lock = window_state.as_ref().lock();
1509+
if lock.transparent_titlebar {
1510+
unsafe {
1511+
lock.native_window.setTitlebarAppearsTransparent_(YES);
1512+
}
1513+
}
14931514
}
14941515

14951516
extern "C" fn window_did_move(this: &Object, _: Sel, _: id) {

0 commit comments

Comments
 (0)