mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 22:42:48 +03:00
windows: improve hit test for integrated max button
refs: https://github.com/wez/wezterm/issues/3499 but isn't the cause of it
This commit is contained in:
parent
ba64239c0a
commit
f627d6d704
@ -526,7 +526,14 @@ impl super::TermWindow {
|
||||
context.set_window_drag_position(event.screen_coords);
|
||||
}
|
||||
TabBarItem::WindowButton(window::IntegratedTitleButton::Maximize) => {
|
||||
context.set_maximize_button_position(event.screen_coords);
|
||||
let item = self.last_ui_item.clone().unwrap();
|
||||
let bounds: ::window::ScreenRect = euclid::rect(
|
||||
item.x as isize - (event.coords.x as isize - event.screen_coords.x),
|
||||
item.y as isize - (event.coords.y as isize - event.screen_coords.y),
|
||||
item.width as isize,
|
||||
item.height as isize,
|
||||
);
|
||||
context.set_maximize_button_position(bounds);
|
||||
}
|
||||
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 set_maximize_button_position(&self, _coords: ScreenPoint) {}
|
||||
fn set_maximize_button_position(&self, _rect: ScreenRect) {}
|
||||
|
||||
/// Requests the windowing system to start a window drag.
|
||||
///
|
||||
|
@ -4,7 +4,7 @@ use crate::parameters::{self, Parameters};
|
||||
use crate::{
|
||||
Appearance, Clipboard, DeadKeyStatus, Dimensions, Handled, KeyCode, KeyEvent, Modifiers,
|
||||
MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, Point, RawKeyEvent, Rect,
|
||||
RequestedWindowGeometry, ResolvedGeometry, ScreenPoint, ULength, WindowDecorations,
|
||||
RequestedWindowGeometry, ResolvedGeometry, ScreenPoint, ScreenRect, ULength, WindowDecorations,
|
||||
WindowEvent, WindowEventSender, WindowOps, WindowState,
|
||||
};
|
||||
use anyhow::{bail, Context};
|
||||
@ -105,7 +105,7 @@ pub(crate) struct WindowInner {
|
||||
saved_placement: Option<WINDOWPLACEMENT>,
|
||||
track_mouse_leave: bool,
|
||||
window_drag_position: Option<ScreenPoint>,
|
||||
maximize_button_position: Option<ScreenPoint>,
|
||||
maximize_button_position: Option<ScreenRect>,
|
||||
|
||||
keyboard_info: KeyboardLayoutInfo,
|
||||
appearance: Appearance,
|
||||
@ -874,7 +874,7 @@ impl WindowOps for Window {
|
||||
});
|
||||
}
|
||||
|
||||
fn set_maximize_button_position(&self, coords: ScreenPoint) {
|
||||
fn set_maximize_button_position(&self, coords: ScreenRect) {
|
||||
Connection::with_window_inner(self.0, move |inner| {
|
||||
inner.maximize_button_position = Some(coords);
|
||||
Ok(())
|
||||
@ -1113,7 +1113,7 @@ unsafe fn wm_nccalcsize(hwnd: HWND, _msg: UINT, wparam: WPARAM, lparam: LPARAM)
|
||||
|
||||
unsafe fn wm_nchittest(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) -> Option<LRESULT> {
|
||||
let inner = rc_from_hwnd(hwnd)?;
|
||||
let mut inner = match inner.try_borrow_mut() {
|
||||
let inner = match inner.try_borrow() {
|
||||
Ok(inner) => inner,
|
||||
Err(_) => {
|
||||
// We've been called recursively and the upper levels
|
||||
@ -1197,8 +1197,10 @@ unsafe fn wm_nchittest(hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM) ->
|
||||
|
||||
let use_snap_layouts = !*IS_WIN10;
|
||||
if use_snap_layouts {
|
||||
if inner.maximize_button_position.take().is_some() {
|
||||
return Some(HTMAXBUTTON);
|
||||
if let Some(max) = inner.maximize_button_position {
|
||||
if max.contains(screen_point) {
|
||||
return Some(HTMAXBUTTON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user