Touch events emit screen coordinates instead of client coordinates on Windows (#1042)

* Touch events emit screen coordinates instead of client coordinates on Windows

Fixes #1002

* Don't lose precision of WM_TOUCH events when converting from screen space to client space

* Updated CHANGELOG.md to reflect changes from issue: #1042
This commit is contained in:
dam4rus 2019-07-17 18:25:35 +02:00 committed by Osspial
parent e8e4d4ce66
commit 8567758156
2 changed files with 23 additions and 4 deletions

View file

@ -18,6 +18,7 @@ and `WindowEvent::HoveredFile`.
- On Windows, fix the trail effect happening on transparent decorated windows. Borderless (or un-decorated) windows were not affected.
- On Windows, fix `with_maximized` not properly setting window size to entire window.
- On macOS, change `WindowExtMacOS::request_user_attention()` to take an `enum` instead of a `bool`.
- On Windows, location of `WindowEvent::Touch` are window client coordinates instead of screen coordinates.
# 0.20.0 Alpha 1 (2019-06-21)

View file

@ -1448,8 +1448,17 @@ unsafe extern "system" fn public_window_callback<T>(
{
let dpi_factor = hwnd_scale_factor(window);
for input in &inputs {
let x = (input.x as f64) / 100f64;
let y = (input.y as f64) / 100f64;
let mut location = POINT {
x: input.x / 100,
y: input.y / 100,
};
if winuser::ScreenToClient(window, &mut location as *mut _) == 0 {
continue;
}
let x = location.x as f64 + (input.x % 100) as f64 / 100f64;
let y = location.y as f64 + (input.y % 100) as f64 / 100f64;
let location = LogicalPosition::from_physical((x, y), dpi_factor);
subclass_input.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),
@ -1510,8 +1519,17 @@ unsafe extern "system" fn public_window_callback<T>(
// The information retrieved appears in reverse chronological order, with the most recent entry in the first
// row of the returned array
for pointer_info in pointer_infos.iter().rev() {
let x = pointer_info.ptPixelLocation.x as f64;
let y = pointer_info.ptPixelLocation.y as f64;
let mut location = POINT {
x: pointer_info.ptPixelLocation.x,
y: pointer_info.ptPixelLocation.y,
};
if winuser::ScreenToClient(window, &mut location as *mut _) == 0 {
continue;
}
let x = location.x as f64;
let y = location.y as f64;
let location = LogicalPosition::from_physical((x, y), dpi_factor);
subclass_input.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),