mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 06:11:30 +11:00
fix issues in wait_until_time_or_msg function (#1423)
also removed unused return value
This commit is contained in:
parent
76d0dd7ec3
commit
522a6e3298
|
@ -1,5 +1,6 @@
|
|||
# Unreleased
|
||||
|
||||
- On Windows, fix minor timing issue in wait_until_time_or_msg
|
||||
- On macOS, fix `set_simple_screen` to remember frame excluding title bar.
|
||||
- On Wayland, fix coordinates in touch events when scale factor isn't 1.
|
||||
- On Wayland, fix color from `close_button_icon_color` not applying.
|
||||
|
|
|
@ -320,11 +320,9 @@ fn main_thread_id() -> DWORD {
|
|||
unsafe { MAIN_THREAD_ID }
|
||||
}
|
||||
|
||||
// Returns true if the wait time was reached, and false if a message must be processed.
|
||||
unsafe fn wait_until_time_or_msg(wait_until: Instant) -> bool {
|
||||
let mut msg = mem::zeroed();
|
||||
unsafe fn wait_until_time_or_msg(wait_until: Instant) {
|
||||
let now = Instant::now();
|
||||
if now <= wait_until {
|
||||
if now < wait_until {
|
||||
// MsgWaitForMultipleObjects tends to overshoot just a little bit. We subtract 1 millisecond
|
||||
// from the requested time and spinlock for the remainder to compensate for that.
|
||||
let resume_reason = winuser::MsgWaitForMultipleObjectsEx(
|
||||
|
@ -336,16 +334,16 @@ unsafe fn wait_until_time_or_msg(wait_until: Instant) -> bool {
|
|||
);
|
||||
|
||||
if resume_reason == winerror::WAIT_TIMEOUT {
|
||||
let mut msg = mem::zeroed();
|
||||
while Instant::now() < wait_until {
|
||||
if 0 != winuser::PeekMessageW(&mut msg, ptr::null_mut(), 0, 0, 0) {
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// Implementation taken from https://github.com/rust-lang/rust/blob/db5476571d9b27c862b95c1e64764b0ac8980e23/src/libstd/sys/windows/mod.rs
|
||||
fn dur2timeout(dur: Duration) -> DWORD {
|
||||
// Note that a duration is a (u64, u32) (seconds, nanoseconds) pair, and the
|
||||
|
|
Loading…
Reference in a new issue