@@ -11,6 +11,7 @@ use windows::Win32::System::SystemServices::MODIFIERKEYS_FLAGS;
1111use windows_core:: Ref ;
1212use windows_sys:: Win32 :: {
1313 Foundation :: POINT , Graphics :: Gdi :: ScreenToClient , UI :: Shell :: DragQueryFileW ,
14+ UI :: WindowsAndMessaging :: GetCursorPos ,
1415} ;
1516
1617use crate :: { DropData , DropEffect , Event , EventStatus , MouseEvent , PhyPoint , Point } ;
@@ -61,14 +62,25 @@ impl DropTarget {
6162 }
6263 }
6364
64- fn parse_coordinates ( & self , pt : POINTL ) {
65+ fn parse_coordinates ( & self , _pt : POINTL ) {
6566 let Some ( window_state) = self . window_state . upgrade ( ) else {
6667 return ;
6768 } ;
68- let mut pt = POINT { x : pt. x , y : pt. y } ;
69- unsafe { ScreenToClient ( window_state. hwnd , & mut pt as * mut POINT ) } ;
70- let phy_point = PhyPoint :: new ( pt. x , pt. y ) ;
71- self . drag_position . set ( phy_point. to_logical ( & window_state. window_info ( ) ) ) ;
69+ // OLE-supplied points can disagree with the actual cursor position for embedded
70+ // child windows (DPI virtualization / DragEnter quirks). Query the cursor directly
71+ // so drag coordinates match WM_MOUSEMOVE.
72+ let mut pt = POINT { x : 0 , y : 0 } ;
73+ unsafe {
74+ GetCursorPos ( & mut pt as * mut POINT ) ;
75+ ScreenToClient ( window_state. hwnd , & mut pt as * mut POINT ) ;
76+ }
77+ let logical_point = if window_state. has_parent ( ) {
78+ // If the window has a parent, the coordinates are already in logical coordinates
79+ Point :: new ( pt. x as f64 , pt. y as f64 )
80+ } else {
81+ PhyPoint :: new ( pt. x , pt. y ) . to_logical ( & window_state. window_info ( ) )
82+ } ;
83+ self . drag_position . set ( logical_point) ;
7284 }
7385
7486 fn parse_drop_data ( & self , data_object : & IDataObject ) {
0 commit comments