@@ -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.
@@ -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
}