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: Allow repositioning macOS traffic lights at runtime (#58169)

Mayank Verma137eeea67be1
diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs
index fe93222a505..321f67b473d 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<Pixels>) {}
fn show_character_palette(&self) {}
fn titlebar_double_click(&self) {}
fn on_move_tab_to_new_window(&self, _callback: Box<dyn FnMut()>) {}
diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs
index f5292840299..161891187a1 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<Pixels>) {
+ 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 68cb31d9ea5..7ecfccfa1cc 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<Pixels>) {
+ 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()
}