From 137eeea67be12540b91e41014339c91a63febcd1 Mon Sep 17 00:00:00 2001 From: Mayank Verma Date: Mon, 1 Jun 2026 12:51:45 +0530 Subject: [PATCH] gpui: Allow repositioning macOS traffic lights at runtime (#58169) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [ ] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A Right now we can only set the traffic light position when creating a window. This adds a public API so that we can update the position at runtime, such as when titlebar height or layout changes dynamically. --- crates/gpui/src/platform.rs | 2 ++ crates/gpui/src/window.rs | 6 ++++++ crates/gpui_macos/src/window.rs | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index fe93222a50..321f67b473 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -670,6 +670,8 @@ pub trait PlatformWindow: HasWindowHandle + HasDisplayHandle { } fn set_edited(&mut self, _edited: bool) {} fn set_document_path(&self, _path: Option<&std::path::Path>) {} + #[cfg(target_os = "macos")] + fn set_traffic_light_position(&self, _position: Point) {} fn show_character_palette(&self) {} fn titlebar_double_click(&self) {} fn on_move_tab_to_new_window(&self, _callback: Box) {} diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index f529284029..161891187a 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -2311,6 +2311,12 @@ impl Window { self.platform_window.set_title(title); } + /// Sets the position of the macOS traffic light buttons. + #[cfg(target_os = "macos")] + pub fn set_traffic_light_position(&self, position: Point) { + self.platform_window.set_traffic_light_position(position); + } + /// Sets the application identifier. pub fn set_app_id(&mut self, app_id: &str) { self.platform_window.set_app_id(app_id); diff --git a/crates/gpui_macos/src/window.rs b/crates/gpui_macos/src/window.rs index 68cb31d9ea..7ecfccfa1c 100644 --- a/crates/gpui_macos/src/window.rs +++ b/crates/gpui_macos/src/window.rs @@ -1188,6 +1188,12 @@ impl PlatformWindow for MacWindow { } } + fn set_traffic_light_position(&self, position: Point) { + let mut state = self.0.lock(); + state.traffic_light_position = Some(position); + state.move_traffic_light(); + } + fn scale_factor(&self) -> f32 { self.0.as_ref().lock().scale_factor() }