fix(windows): Multi-monitor different scaling window size issue (#858)

* Fix the issue where the window size is abnormal when dragging between monitors with different scaling settings with the "Show window contents while dragging" option turned off in Windows.

* clean code

* fix code fmt;

* Optimize code

* delete not used mut keyword

* add change file
This commit is contained in:
MoChenYa
2024-01-10 19:22:24 +08:00
committed by GitHub
parent f0bf850fee
commit 60bbcac168
2 changed files with 23 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
"tao": "patch"
---
On Windows, fix when the `Show window contents while dragging` setting is turned off in Windows, there is a window size issue when dragging between multi-monitors with different scaling.

View File

@@ -1919,6 +1919,11 @@ unsafe fn public_window_callback_inner<T: 'static>(
false => old_physical_inner_size,
};
// When the "Show window contents while dragging" is turned off, there is no need to adjust the window size.
if !is_show_window_contents_while_dragging_enabled() {
new_physical_inner_size = old_physical_inner_size;
}
subclass_input.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window.0)),
event: ScaleFactorChanged {
@@ -2191,6 +2196,19 @@ unsafe fn public_window_callback_inner<T: 'static>(
}
}
fn is_show_window_contents_while_dragging_enabled() -> bool {
let mut is_enabled: BOOL = BOOL(0);
let result = unsafe {
SystemParametersInfoW(
SPI_GETDRAGFULLWINDOWS,
0,
Option::from(&mut is_enabled as *mut _ as *mut std::ffi::c_void),
SYSTEM_PARAMETERS_INFO_UPDATE_FLAGS(0),
)
};
result.is_ok() && is_enabled.0 != 0
}
unsafe extern "system" fn thread_event_target_callback<T: 'static>(
window: HWND,
msg: u32,