From 12c7b62b90249d4fe565c304d6aafbb8fe5c5019 Mon Sep 17 00:00:00 2001 From: Smit Barmase Date: Wed, 19 Aug 2026 14:46:01 +0000 Subject: [PATCH] gpui_macos: Fix fullscreen behavior on non-macOS and after restart (#62819) Follow-up to #60020. - Fixes simple fullscreen preventing fullscreen from working on Linux and Windows (since I use shared dotfiles). - Fixes quitting Zed in simple fullscreen not correctly restoring the previous window bounds, causing it to reopen maximized. We are not handling opening it back in simple fullscreen yet. Release Notes: - N/A --- crates/gpui_macos/src/window.rs | 5 +++++ crates/zed/src/zed.rs | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rs index 80f5373eb8..faf27e036b 100644 --- a/crates/gpui_macos/src/window.rs +++ b/crates/gpui_macos/src/window.rs @@ -505,6 +505,7 @@ const NS_APPLICATION_PRESENTATION_AUTO_HIDE_MENU_BAR: NSUInteger = 1 << 2; // the window on exit. struct SimpleFullscreenState { frame: NSRect, + bounds: Bounds, style_mask: NSWindowStyleMask, } @@ -818,9 +819,11 @@ impl MacWindowState { return None; } let screen_frame = unsafe { NSScreen::frame(screen) }; + let bounds = self.bounds(); self.simple_fullscreen_state = Some(SimpleFullscreenState { frame: unsafe { NSWindow::frame(self.native_window) }, + bounds, style_mask: unsafe { self.native_window.styleMask() }, }); @@ -865,6 +868,8 @@ impl MacWindowState { fn window_bounds(&self) -> WindowBounds { if self.is_fullscreen() { WindowBounds::Fullscreen(self.fullscreen_restore_bounds) + } else if let Some(state) = &self.simple_fullscreen_state { + WindowBounds::Windowed(state.bounds) } else { WindowBounds::Windowed(self.bounds()) } diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 5b95dd32a5..85fc30055d 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1026,10 +1026,11 @@ fn register_actions( window.zoom_window(); }) .register_action(|_, _: &ToggleFullScreen, window, cx| { - let use_simple_fullscreen = window.is_simple_fullscreen() - || (!window.is_fullscreen() - && WorkspaceSettings::get_global(cx).fullscreen_mode - == settings::FullscreenMode::Simple); + let use_simple_fullscreen = PlatformStyle::platform() == PlatformStyle::Mac + && (window.is_simple_fullscreen() + || (!window.is_fullscreen() + && WorkspaceSettings::get_global(cx).fullscreen_mode + == settings::FullscreenMode::Simple)); if use_simple_fullscreen { window.toggle_simple_fullscreen(); } else {