@@ -17,8 +17,8 @@ use windows_sys::Win32::Foundation::{
1717 GetLastError , FALSE , HANDLE , HWND , LPARAM , LRESULT , POINT , RECT , WAIT_FAILED , WPARAM ,
1818} ;
1919use windows_sys:: Win32 :: Graphics :: Gdi :: {
20- GetMonitorInfoW , MonitorFromRect , MonitorFromWindow , RedrawWindow , ScreenToClient ,
21- ValidateRect , MONITORINFO , MONITOR_DEFAULTTONULL , RDW_INTERNALPAINT , SC_SCREENSAVE ,
20+ MonitorFromRect , RedrawWindow , ScreenToClient , ValidateRect , MONITOR_DEFAULTTONULL ,
21+ RDW_INTERNALPAINT , SC_SCREENSAVE ,
2222} ;
2323use windows_sys:: Win32 :: System :: Ole :: RevokeDragDrop ;
2424use windows_sys:: Win32 :: System :: Threading :: {
@@ -2477,65 +2477,7 @@ unsafe fn public_window_callback_inner(
24772477 conservative_rect. right += bias;
24782478 }
24792479
2480- // Check to see if the new window rect is on the monitor with the new DPI factor.
2481- // If it isn't, offset the window so that it is.
2482- let new_dpi_monitor = unsafe { MonitorFromWindow ( window, MONITOR_DEFAULTTONULL ) } ;
2483- let conservative_rect_monitor =
2484- unsafe { MonitorFromRect ( & conservative_rect, MONITOR_DEFAULTTONULL ) } ;
2485- new_outer_rect = if conservative_rect_monitor == new_dpi_monitor {
2486- conservative_rect
2487- } else {
2488- let get_monitor_rect = |monitor| {
2489- let mut monitor_info = MONITORINFO {
2490- cbSize : mem:: size_of :: < MONITORINFO > ( ) as _ ,
2491- ..unsafe { mem:: zeroed ( ) }
2492- } ;
2493- unsafe { GetMonitorInfoW ( monitor, & mut monitor_info) } ;
2494- monitor_info. rcMonitor
2495- } ;
2496- let wrong_monitor = conservative_rect_monitor;
2497- let wrong_monitor_rect = get_monitor_rect ( wrong_monitor) ;
2498- let new_monitor_rect = get_monitor_rect ( new_dpi_monitor) ;
2499-
2500- // The direction to nudge the window in to get the window onto the monitor with
2501- // the new DPI factor. We calculate this by seeing which monitor edges are
2502- // shared and nudging away from the wrong monitor based on those.
2503- #[ allow( clippy:: bool_to_int_with_if) ]
2504- let delta_nudge_to_dpi_monitor = (
2505- if wrong_monitor_rect. left == new_monitor_rect. right {
2506- -1
2507- } else if wrong_monitor_rect. right == new_monitor_rect. left {
2508- 1
2509- } else {
2510- 0
2511- } ,
2512- if wrong_monitor_rect. bottom == new_monitor_rect. top {
2513- 1
2514- } else if wrong_monitor_rect. top == new_monitor_rect. bottom {
2515- -1
2516- } else {
2517- 0
2518- } ,
2519- ) ;
2520-
2521- let abort_after_iterations = new_monitor_rect. right - new_monitor_rect. left
2522- + new_monitor_rect. bottom
2523- - new_monitor_rect. top ;
2524- for _ in 0 ..abort_after_iterations {
2525- conservative_rect. left += delta_nudge_to_dpi_monitor. 0 ;
2526- conservative_rect. right += delta_nudge_to_dpi_monitor. 0 ;
2527- conservative_rect. top += delta_nudge_to_dpi_monitor. 1 ;
2528- conservative_rect. bottom += delta_nudge_to_dpi_monitor. 1 ;
2529-
2530- if unsafe { MonitorFromRect ( & conservative_rect, MONITOR_DEFAULTTONULL ) }
2531- == new_dpi_monitor
2532- {
2533- break ;
2534- }
2535- }
2536-
2537- conservative_rect
2538- } ;
2480+ new_outer_rect = conservative_rect;
25392481 }
25402482
25412483 unsafe {
0 commit comments