From 17a240cd43638b43c03eba0044ecc69ef219061b Mon Sep 17 00:00:00 2001 From: Osspial Date: Tue, 19 Mar 2019 22:19:41 -0400 Subject: [PATCH] On Windows, fix CursorMoved(0, 0) getting sent on focus (#819) * On Windows, fix CursorMoved(0, 0) getting sent on focus * Add changelog entry --- CHANGELOG.md | 2 ++ src/platform_impl/windows/event_loop.rs | 12 +----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8036e74e..725253d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,8 @@ - Rename `MonitorId` to `MonitorHandle`. - Removed `serde` implementations from `ControlFlow`. +- On Windows, fix `CursorMoved(0, 0)` getting dispatched on window focus. + # Version 0.19.0 (2019-03-06) - On X11, we will use the faster `XRRGetScreenResourcesCurrent` function instead of `XRRGetScreenResources` when available. diff --git a/src/platform_impl/windows/event_loop.rs b/src/platform_impl/windows/event_loop.rs index ad4f3997..a820ba5d 100644 --- a/src/platform_impl/windows/event_loop.rs +++ b/src/platform_impl/windows/event_loop.rs @@ -1335,22 +1335,12 @@ unsafe extern "system" fn public_window_callback( } winuser::WM_SETFOCUS => { - use event::WindowEvent::{Focused, CursorMoved}; + use event::WindowEvent::Focused; subclass_input.send_event(Event::WindowEvent { window_id: RootWindowId(WindowId(window)), event: Focused(true), }); - let x = windowsx::GET_X_LPARAM(lparam) as f64; - let y = windowsx::GET_Y_LPARAM(lparam) as f64; - let dpi_factor = get_hwnd_scale_factor(window); - let position = LogicalPosition::from_physical((x, y), dpi_factor); - - subclass_input.send_event(Event::WindowEvent { - window_id: RootWindowId(WindowId(window)), - event: CursorMoved { device_id: DEVICE_ID, position, modifiers: event::get_key_mods() }, - }); - 0 },