mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 10:26:34 +11:00
Fix assigning the wrong monitor when receiving Windows move events (#2266)
Co-authored-by: kas <exactly-one-kas@users.noreply.github.com>
This commit is contained in:
parent
ce890c3455
commit
e7f88588bf
2 changed files with 73 additions and 39 deletions
|
@ -39,6 +39,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On iOS, send `RedrawEventsCleared` even if there are no redraw events, consistent with other platforms.
|
- On iOS, send `RedrawEventsCleared` even if there are no redraw events, consistent with other platforms.
|
||||||
- **Breaking:** Replaced `Window::with_app_id` and `Window::with_class` with `Window::with_name` on `WindowBuilderExtUnix`.
|
- **Breaking:** Replaced `Window::with_app_id` and `Window::with_class` with `Window::with_name` on `WindowBuilderExtUnix`.
|
||||||
- On Wayland and X11, fix window not resizing with `Window::set_inner_size` after calling `Window:set_resizable(false)`.
|
- On Wayland and X11, fix window not resizing with `Window::set_inner_size` after calling `Window:set_resizable(false)`.
|
||||||
|
- On Windows, fix wrong fullscreen monitors being recognized when handling WM_WINDOWPOSCHANGING messages
|
||||||
|
|
||||||
# 0.26.1 (2022-01-05)
|
# 0.26.1 (2022-01-05)
|
||||||
|
|
||||||
|
|
|
@ -56,17 +56,17 @@ use windows_sys::Win32::{
|
||||||
GIDC_ARRIVAL, GIDC_REMOVAL, GWL_EXSTYLE, GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT,
|
GIDC_ARRIVAL, GIDC_REMOVAL, GWL_EXSTYLE, GWL_STYLE, GWL_USERDATA, HTCAPTION, HTCLIENT,
|
||||||
MAPVK_VK_TO_VSC, MINMAXINFO, MSG, MWMO_INPUTAVAILABLE, PM_NOREMOVE, PM_QS_PAINT,
|
MAPVK_VK_TO_VSC, MINMAXINFO, MSG, MWMO_INPUTAVAILABLE, PM_NOREMOVE, PM_QS_PAINT,
|
||||||
PM_REMOVE, PT_PEN, PT_TOUCH, QS_ALLEVENTS, RI_KEY_E0, RI_KEY_E1, RI_MOUSE_WHEEL,
|
PM_REMOVE, PT_PEN, PT_TOUCH, QS_ALLEVENTS, RI_KEY_E0, RI_KEY_E1, RI_MOUSE_WHEEL,
|
||||||
SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOZORDER,
|
SC_MINIMIZE, SC_RESTORE, SIZE_MAXIMIZED, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOSIZE,
|
||||||
WHEEL_DELTA, WINDOWPOS, WM_CAPTURECHANGED, WM_CHAR, WM_CLOSE, WM_CREATE, WM_DESTROY,
|
SWP_NOZORDER, WHEEL_DELTA, WINDOWPOS, WM_CAPTURECHANGED, WM_CHAR, WM_CLOSE, WM_CREATE,
|
||||||
WM_DPICHANGED, WM_DROPFILES, WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE, WM_GETMINMAXINFO,
|
WM_DESTROY, WM_DPICHANGED, WM_DROPFILES, WM_ENTERSIZEMOVE, WM_EXITSIZEMOVE,
|
||||||
WM_INPUT, WM_INPUT_DEVICE_CHANGE, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS, WM_LBUTTONDOWN,
|
WM_GETMINMAXINFO, WM_INPUT, WM_INPUT_DEVICE_CHANGE, WM_KEYDOWN, WM_KEYUP, WM_KILLFOCUS,
|
||||||
WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEHWHEEL, WM_MOUSEMOVE,
|
WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MOUSEHWHEEL,
|
||||||
WM_MOUSEWHEEL, WM_NCCREATE, WM_NCDESTROY, WM_NCLBUTTONDOWN, WM_PAINT, WM_POINTERDOWN,
|
WM_MOUSEMOVE, WM_MOUSEWHEEL, WM_NCCREATE, WM_NCDESTROY, WM_NCLBUTTONDOWN, WM_PAINT,
|
||||||
WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR,
|
WM_POINTERDOWN, WM_POINTERUP, WM_POINTERUPDATE, WM_RBUTTONDOWN, WM_RBUTTONUP,
|
||||||
WM_SETFOCUS, WM_SETTINGCHANGE, WM_SIZE, WM_SYSCHAR, WM_SYSCOMMAND, WM_SYSKEYDOWN,
|
WM_SETCURSOR, WM_SETFOCUS, WM_SETTINGCHANGE, WM_SIZE, WM_SYSCHAR, WM_SYSCOMMAND,
|
||||||
WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING, WM_XBUTTONDOWN,
|
WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TOUCH, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING,
|
||||||
WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE, WS_EX_TOOLWINDOW,
|
WM_XBUTTONDOWN, WM_XBUTTONUP, WNDCLASSEXW, WS_EX_LAYERED, WS_EX_NOACTIVATE,
|
||||||
WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE,
|
WS_EX_TOOLWINDOW, WS_EX_TRANSPARENT, WS_OVERLAPPED, WS_POPUP, WS_VISIBLE,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -980,6 +980,37 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
right: window_pos.x + window_pos.cx,
|
right: window_pos.x + window_pos.cx,
|
||||||
bottom: window_pos.y + window_pos.cy,
|
bottom: window_pos.y + window_pos.cy,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const NOMOVE_OR_NOSIZE: u32 = SWP_NOMOVE | SWP_NOSIZE;
|
||||||
|
|
||||||
|
let new_rect = if window_pos.flags & NOMOVE_OR_NOSIZE != 0 {
|
||||||
|
let cur_rect = util::get_window_rect(window)
|
||||||
|
.expect("Unexpected GetWindowRect failure; please report this error to https://github.com/rust-windowing/winit");
|
||||||
|
|
||||||
|
match window_pos.flags & NOMOVE_OR_NOSIZE {
|
||||||
|
NOMOVE_OR_NOSIZE => None,
|
||||||
|
|
||||||
|
SWP_NOMOVE => Some(RECT {
|
||||||
|
left: cur_rect.left,
|
||||||
|
top: cur_rect.top,
|
||||||
|
right: cur_rect.left + window_pos.cx,
|
||||||
|
bottom: cur_rect.top + window_pos.cy,
|
||||||
|
}),
|
||||||
|
|
||||||
|
SWP_NOSIZE => Some(RECT {
|
||||||
|
left: window_pos.x,
|
||||||
|
top: window_pos.y,
|
||||||
|
right: window_pos.x - cur_rect.left + cur_rect.right,
|
||||||
|
bottom: window_pos.y - cur_rect.top + cur_rect.bottom,
|
||||||
|
}),
|
||||||
|
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Some(new_rect)
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(new_rect) = new_rect {
|
||||||
let new_monitor = MonitorFromRect(&new_rect, MONITOR_DEFAULTTONULL);
|
let new_monitor = MonitorFromRect(&new_rect, MONITOR_DEFAULTTONULL);
|
||||||
match fullscreen {
|
match fullscreen {
|
||||||
Fullscreen::Borderless(ref mut fullscreen_monitor) => {
|
Fullscreen::Borderless(ref mut fullscreen_monitor) => {
|
||||||
|
@ -989,7 +1020,8 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
.map(|monitor| new_monitor != monitor.inner.hmonitor())
|
.map(|monitor| new_monitor != monitor.inner.hmonitor())
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
{
|
{
|
||||||
if let Ok(new_monitor_info) = monitor::get_monitor_info(new_monitor) {
|
if let Ok(new_monitor_info) = monitor::get_monitor_info(new_monitor)
|
||||||
|
{
|
||||||
let new_monitor_rect = new_monitor_info.monitorInfo.rcMonitor;
|
let new_monitor_rect = new_monitor_info.monitorInfo.rcMonitor;
|
||||||
window_pos.x = new_monitor_rect.left;
|
window_pos.x = new_monitor_rect.left;
|
||||||
window_pos.y = new_monitor_rect.top;
|
window_pos.y = new_monitor_rect.top;
|
||||||
|
@ -1013,6 +1045,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue