mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 10:26:34 +11:00
windows: ignore spurious mouse move messages (#1435)
Fixes https://github.com/rust-windowing/winit/issues/1428
This commit is contained in:
parent
b8326f6452
commit
71bd6e73ca
3 changed files with 23 additions and 10 deletions
|
@ -9,6 +9,7 @@
|
||||||
- On Web, add the ability to query "Light" or "Dark" system theme send `ThemeChanged` on change.
|
- On Web, add the ability to query "Light" or "Dark" system theme send `ThemeChanged` on change.
|
||||||
- Fix `Event::to_static` returning `None` for user events.
|
- Fix `Event::to_static` returning `None` for user events.
|
||||||
- On Wayland, Hide CSD for fullscreen windows.
|
- On Wayland, Hide CSD for fullscreen windows.
|
||||||
|
- On Windows, ignore spurious mouse move messages.
|
||||||
|
|
||||||
# 0.21.0 (2020-02-04)
|
# 0.21.0 (2020-02-04)
|
||||||
|
|
||||||
|
|
|
@ -856,15 +856,25 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
|
||||||
let x = windowsx::GET_X_LPARAM(lparam) as f64;
|
let x = windowsx::GET_X_LPARAM(lparam) as f64;
|
||||||
let y = windowsx::GET_Y_LPARAM(lparam) as f64;
|
let y = windowsx::GET_Y_LPARAM(lparam) as f64;
|
||||||
let position = PhysicalPosition::new(x, y);
|
let position = PhysicalPosition::new(x, y);
|
||||||
|
let cursor_moved;
|
||||||
subclass_input.send_event(Event::WindowEvent {
|
{
|
||||||
window_id: RootWindowId(WindowId(window)),
|
// handle spurious WM_MOUSEMOVE messages
|
||||||
event: CursorMoved {
|
// see https://devblogs.microsoft.com/oldnewthing/20031001-00/?p=42343
|
||||||
device_id: DEVICE_ID,
|
// and http://debugandconquer.blogspot.com/2015/08/the-cause-of-spurious-mouse-move.html
|
||||||
position,
|
let mut w = subclass_input.window_state.lock();
|
||||||
modifiers: event::get_key_mods(),
|
cursor_moved = w.mouse.last_position != Some(position);
|
||||||
},
|
w.mouse.last_position = Some(position);
|
||||||
});
|
}
|
||||||
|
if cursor_moved {
|
||||||
|
subclass_input.send_event(Event::WindowEvent {
|
||||||
|
window_id: RootWindowId(WindowId(window)),
|
||||||
|
event: CursorMoved {
|
||||||
|
device_id: DEVICE_ID,
|
||||||
|
position,
|
||||||
|
modifiers: event::get_key_mods(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
dpi::Size,
|
dpi::{PhysicalPosition, Size},
|
||||||
platform_impl::platform::{event_loop, icon::WinIcon, util},
|
platform_impl::platform::{event_loop, icon::WinIcon, util},
|
||||||
window::{CursorIcon, Fullscreen, WindowAttributes},
|
window::{CursorIcon, Fullscreen, WindowAttributes},
|
||||||
};
|
};
|
||||||
|
@ -48,6 +48,7 @@ pub struct MouseProperties {
|
||||||
pub cursor: CursorIcon,
|
pub cursor: CursorIcon,
|
||||||
pub buttons_down: u32,
|
pub buttons_down: u32,
|
||||||
cursor_flags: CursorFlags,
|
cursor_flags: CursorFlags,
|
||||||
|
pub last_position: Option<PhysicalPosition<f64>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
|
@ -106,6 +107,7 @@ impl WindowState {
|
||||||
cursor: CursorIcon::default(),
|
cursor: CursorIcon::default(),
|
||||||
buttons_down: 0,
|
buttons_down: 0,
|
||||||
cursor_flags: CursorFlags::empty(),
|
cursor_flags: CursorFlags::empty(),
|
||||||
|
last_position: None,
|
||||||
},
|
},
|
||||||
|
|
||||||
min_size: attributes.min_inner_size,
|
min_size: attributes.min_inner_size,
|
||||||
|
|
Loading…
Add table
Reference in a new issue