-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Incorrect position with CursorMoved when dragging out of window left/top with mouse button pressed #2310
Copy link
Copy link
Closed
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - win32Affects the Win32/Windows backendAffects the Win32/Windows backend
Description
The position value received with WindowEvent::CursorMoved { position, .. }, ... is incorrect when a mouse button is being held and the pointer crosses over the left or top edge of the window.
Instead of the proper negative value, position contains 65536.0 - offset to window edge, this is obviously the result of some intermediate conversion to u16 before position is turned into PhysicalPosition<f64> and given to the event. I believe this problem was introduced in the last update to winit, but I am not positive.
For now, I have worked around the problem as follows:
Event::WindowEvent {
event: WindowEvent::CursorMoved { position, .. },
..
} => {
let px = if position.x > 32767.0 {
(position.x - 65536.0)
} else {
position.x
};
let py = if position.y > 32767.0 {
(position.y - 65536.0)
} else {
position.y
};
// ... use `vec2(px, py)` instead of `position`...
I have only tried this on Windows, I am not sure the problem exists on other platforms.
A=
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
B - bugDang, that shouldn't have happenedDang, that shouldn't have happenedDS - win32Affects the Win32/Windows backendAffects the Win32/Windows backend