Skip to content

Commit bf7bfa8

Browse files
committed
Fix resize lag when waiting in some situations
1 parent 70722cc commit bf7bfa8

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/platform_impl/windows/event_loop.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use winapi::shared::minwindef::{
3737
WPARAM,
3838
};
3939
use winapi::shared::windef::{HWND, POINT, RECT};
40-
use winapi::shared::windowsx;
40+
use winapi::shared::{windowsx, winerror};
4141
use winapi::um::{winuser, winbase, ole2, processthreadsapi, commctrl, libloaderapi};
4242
use winapi::um::winnt::{LONG, LPCSTR, SHORT};
4343

@@ -481,16 +481,19 @@ unsafe fn wait_until_time_or_msg(wait_until: Instant) -> bool {
481481
if now <= wait_until {
482482
// MsgWaitForMultipleObjects tends to overshoot just a little bit. We subtract 1 millisecond
483483
// from the requested time and spinlock for the remainder to compensate for that.
484-
winuser::MsgWaitForMultipleObjects(
484+
let resume_reason = winuser::MsgWaitForMultipleObjectsEx(
485485
0,
486486
ptr::null(),
487-
1,
488487
dur2timeout(wait_until - now).saturating_sub(1),
489-
winuser::QS_ALLINPUT
488+
winuser::QS_ALLEVENTS,
489+
winuser::MWMO_INPUTAVAILABLE
490490
);
491-
while Instant::now() < wait_until {
492-
if 0 != winuser::PeekMessageW(&mut msg, ptr::null_mut(), 0, 0, 0) {
493-
return false;
491+
492+
if resume_reason == winerror::WAIT_TIMEOUT {
493+
while Instant::now() < wait_until {
494+
if 0 != winuser::PeekMessageW(&mut msg, ptr::null_mut(), 0, 0, 0) {
495+
return false;
496+
}
494497
}
495498
}
496499
}

0 commit comments

Comments
 (0)