diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 51fd692f86805886529f17f03feea8bf7ff9db03..3505da3e7d85ed3dca5e9050787d11902941f364 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -1819,6 +1819,7 @@ impl Window { self.platform_window.show_window_menu(position) } + /// Handle window movement for Linux and macOS. /// Tells the compositor to take control of window movement (Wayland and X11) /// /// Events may not be received during a move operation. diff --git a/crates/title_bar/src/platform_title_bar.rs b/crates/title_bar/src/platform_title_bar.rs index fd03e764629454411c9726ef7dcf055d54582d7e..c40934c5ccfc41fecfdaa13131bd8c61b421f0dc 100644 --- a/crates/title_bar/src/platform_title_bar.rs +++ b/crates/title_bar/src/platform_title_bar.rs @@ -77,6 +77,29 @@ impl Render for PlatformTitleBar { .window_control_area(WindowControlArea::Drag) .w_full() .h(height) + .map(|this| { + this.on_mouse_down_out(cx.listener(move |this, _ev, _window, _cx| { + this.should_move = false; + })) + .on_mouse_up( + gpui::MouseButton::Left, + cx.listener(move |this, _ev, _window, _cx| { + this.should_move = false; + }), + ) + .on_mouse_down( + gpui::MouseButton::Left, + cx.listener(move |this, _ev, _window, _cx| { + this.should_move = true; + }), + ) + .on_mouse_move(cx.listener(move |this, _ev, window, _| { + if this.should_move { + this.should_move = false; + window.start_window_move(); + } + })) + }) .map(|this| { if window.is_fullscreen() { this.pl_2() @@ -113,13 +136,6 @@ impl Render for PlatformTitleBar { .overflow_x_hidden() .w_full() // Note: On Windows the title bar behavior is handled by the platform implementation. - .when(self.platform_style == PlatformStyle::Mac, |this| { - this.on_click(|event, window, _| { - if event.click_count() == 2 { - window.titlebar_double_click(); - } - }) - }) .when(self.platform_style == PlatformStyle::Linux, |this| { this.on_click(|event, window, _| { if event.click_count() == 2 { @@ -142,27 +158,6 @@ impl Render for PlatformTitleBar { window.show_window_menu(ev.position) }) }) - .on_mouse_move(cx.listener(move |this, _ev, window, _| { - if this.should_move { - this.should_move = false; - window.start_window_move(); - } - })) - .on_mouse_down_out(cx.listener(move |this, _ev, _window, _cx| { - this.should_move = false; - })) - .on_mouse_up( - MouseButton::Left, - cx.listener(move |this, _ev, _window, _cx| { - this.should_move = false; - }), - ) - .on_mouse_down( - MouseButton::Left, - cx.listener(move |this, _ev, _window, _cx| { - this.should_move = true; - }), - ) } else { title_bar }