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.

Add double click to zoom the window

Conrad Irwin803d2b671062
diff --git a/crates/gpui2/src/platform/mac/window.rs b/crates/gpui2/src/platform/mac/window.rs
index 52dcf316037..affeab57c75 100644
--- a/crates/gpui2/src/platform/mac/window.rs
+++ b/crates/gpui2/src/platform/mac/window.rs
@@ -678,10 +678,15 @@ impl MacWindow {
impl Drop for MacWindow {
fn drop(&mut self) {
- let native_window = self.0.lock().native_window;
- unsafe {
- native_window.close();
- }
+ let this = self.0.lock();
+ let window = this.native_window;
+ this.executor
+ .spawn(async move {
+ unsafe {
+ window.close();
+ }
+ })
+ .detach();
}
}
@@ -868,17 +873,25 @@ impl PlatformWindow for MacWindow {
fn zoom(&self) {
let this = self.0.lock();
let window = this.native_window;
- unsafe {
- window.zoom_(nil);
- }
+ this.executor
+ .spawn(async move {
+ unsafe {
+ window.zoom_(nil);
+ }
+ })
+ .detach();
}
fn toggle_full_screen(&self) {
let this = self.0.lock();
let window = this.native_window;
- unsafe {
- window.toggleFullScreen_(nil);
- }
+ this.executor
+ .spawn(async move {
+ unsafe {
+ window.toggleFullScreen_(nil);
+ }
+ })
+ .detach();
}
fn on_input(&self, callback: Box<dyn FnMut(InputEvent) -> bool>) {
diff --git a/crates/gpui2/src/window.rs b/crates/gpui2/src/window.rs
index 8e1022c8903..880f4fc6e6b 100644
--- a/crates/gpui2/src/window.rs
+++ b/crates/gpui2/src/window.rs
@@ -575,6 +575,10 @@ impl<'a> WindowContext<'a> {
self.window.active
}
+ pub fn zoom_window(&self) {
+ self.window.platform_window.zoom();
+ }
+
pub fn display(&self) -> Option<Rc<dyn PlatformDisplay>> {
self.platform
.displays()
diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs
index 3db4900463a..38e01e10b03 100644
--- a/crates/workspace2/src/workspace2.rs
+++ b/crates/workspace2/src/workspace2.rs
@@ -2690,14 +2690,15 @@ impl Workspace {
fn render_titlebar(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
div()
+ .bg(cx.theme().colors().title_bar)
.when(
- matches!(cx.window_bounds(), WindowBounds::Fullscreen),
+ !matches!(cx.window_bounds(), WindowBounds::Fullscreen),
|s| s.pl_20(),
)
- .id(0)
+ .id("titlebar")
.on_click(|workspace, event, cx| {
if event.up.click_count == 2 {
- println!("ZOOOOOM")
+ cx.zoom_window();
}
})
.child("Collab title bar Item") // self.titlebar_item