mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 22:42:48 +03:00
minor tidy up of hover handling for maximize button
Remove an unsafe global variable and replace with a member variable that works similarly to the drag tracking. Doing this from a mac... may not compile on a windows box!
This commit is contained in:
parent
ba34f9608e
commit
2168709836
@ -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 { .. }
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -104,6 +104,7 @@ pub(crate) struct WindowInner {
|
||||
saved_placement: Option<WINDOWPLACEMENT>,
|
||||
track_mouse_leave: bool,
|
||||
window_drag_position: Option<ScreenPoint>,
|
||||
maximize_button_position: Option<ScreenPoint>,
|
||||
|
||||
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<LRESULT> {
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user