diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs index 7c1770041..d70c452b4 100644 --- a/wezterm-gui/src/termwindow/mouseevent.rs +++ b/wezterm-gui/src/termwindow/mouseevent.rs @@ -527,9 +527,7 @@ impl super::TermWindow { context.set_window_drag_position(event.screen_coords); } TabBarItem::WindowButton(window::IntegratedTitleButton::Maximize) => { - if let Some(ref window) = self.window { - window.hover_maximize_button(); - } + context.set_maximize_button_position(event.screen_coords); } TabBarItem::WindowButton(_) | TabBarItem::Tab { .. } diff --git a/window/src/lib.rs b/window/src/lib.rs index 957299cc9..7726ec243 100644 --- a/window/src/lib.rs +++ b/window/src/lib.rs @@ -257,7 +257,7 @@ pub trait WindowOps { fn set_inner_size(&self, width: usize, height: usize); /// Use for windows snap layouts - fn hover_maximize_button(&self) {} + fn set_maximize_button_position(&self, _coords: ScreenPoint) {} /// Requests the windowing system to start a window drag. /// diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs index 7dfb452af..e0730befd 100644 --- a/window/src/os/windows/window.rs +++ b/window/src/os/windows/window.rs @@ -104,6 +104,7 @@ pub(crate) struct WindowInner { saved_placement: Option, track_mouse_leave: bool, window_drag_position: Option, + maximize_button_position: Option, keyboard_info: KeyboardLayoutInfo, appearance: Appearance, @@ -473,6 +474,7 @@ impl Window { saved_placement: None, track_mouse_leave: false, window_drag_position: None, + maximize_button_position: None, config: config.clone(), paint_throttled: false, invalidated: true, @@ -861,10 +863,11 @@ impl WindowOps for Window { }); } - fn hover_maximize_button(&self) { - unsafe { - MAXBTN_HOVERED = true; - } + fn set_maximize_button_position(&self, coords: ScreenPoint) { + Connection::with_window_inner(self.0, move |inner| { + inner.maximize_button_position = Some(coords); + Ok(()) + }); } fn set_window_position(&self, coords: ScreenPoint) { @@ -1088,8 +1091,6 @@ unsafe fn wm_nccalcsize(hwnd: HWND, _msg: UINT, wparam: WPARAM, lparam: LPARAM) Some(0) } -static mut MAXBTN_HOVERED: bool = false; - unsafe fn wm_nchittest(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option { let inner = rc_from_hwnd(hwnd)?; let inner = inner.borrow_mut(); @@ -1168,9 +1169,12 @@ unsafe fn wm_nchittest(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> } let use_snap_layouts = !*IS_WIN10; - if use_snap_layouts && MAXBTN_HOVERED { - MAXBTN_HOVERED = false; - return Some(HTMAXBUTTON); + if use_snap_layouts { + if let Some(coords) = inner.maximize_button_position { + if coords == screen_point { + return Some(HTMAXBUTTON); + } + } } Some(HTCLIENT)