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_macos: Fix fullscreen behavior on non-macOS and after restart (#62819)

Smit Barmase242fe31a399f
diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rs
index 80f5373eb8f..faf27e036b8 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<Pixels>,
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 5b95dd32a51..85fc30055df 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 {