Skip to content

Commit 20dfc85

Browse files
committed
fix drag&drop coordinates on windows (RustAudio#205)
1 parent cb67f29 commit 20dfc85

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/win/drop_target.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::rc::{Rc, Weak};
77
use winapi::shared::guiddef::{IsEqualIID, REFIID};
88
use winapi::shared::minwindef::{DWORD, WPARAM};
99
use winapi::shared::ntdef::{HRESULT, ULONG};
10-
use winapi::shared::windef::POINTL;
10+
use winapi::shared::windef::{POINT, POINTL};
1111
use winapi::shared::winerror::{E_NOINTERFACE, E_UNEXPECTED, S_OK};
1212
use winapi::shared::wtypes::DVASPECT_CONTENT;
1313
use winapi::um::objidl::{IDataObject, FORMATETC, STGMEDIUM, TYMED_HGLOBAL};
@@ -17,7 +17,7 @@ use winapi::um::oleidl::{
1717
};
1818
use winapi::um::shellapi::{DragQueryFileW, HDROP};
1919
use winapi::um::unknwnbase::{IUnknown, IUnknownVtbl};
20-
use winapi::um::winuser::CF_HDROP;
20+
use winapi::um::winuser::{ScreenToClient, CF_HDROP};
2121
use winapi::Interface;
2222

2323
use crate::{DropData, DropEffect, Event, EventStatus, MouseEvent, PhyPoint, Point};
@@ -113,6 +113,9 @@ impl DropTarget {
113113
return;
114114
};
115115

116+
let mut pt = POINT { x: pt.x, y: pt.y };
117+
unsafe { ScreenToClient(window_state.hwnd, &mut pt as *mut POINT) };
118+
116119
let phy_point = PhyPoint::new(pt.x, pt.y);
117120
self.drag_position = phy_point.to_logical(&window_state.window_info());
118121
}

0 commit comments

Comments
 (0)