@@ -37,7 +37,7 @@ use winapi::shared::minwindef::{
37
37
WPARAM ,
38
38
} ;
39
39
use winapi:: shared:: windef:: { HWND , POINT , RECT } ;
40
- use winapi:: shared:: windowsx;
40
+ use winapi:: shared:: { windowsx, winerror } ;
41
41
use winapi:: um:: { winuser, winbase, ole2, processthreadsapi, commctrl, libloaderapi} ;
42
42
use winapi:: um:: winnt:: { LONG , LPCSTR , SHORT } ;
43
43
@@ -481,16 +481,19 @@ unsafe fn wait_until_time_or_msg(wait_until: Instant) -> bool {
481
481
if now <= wait_until {
482
482
// MsgWaitForMultipleObjects tends to overshoot just a little bit. We subtract 1 millisecond
483
483
// from the requested time and spinlock for the remainder to compensate for that.
484
- winuser:: MsgWaitForMultipleObjects (
484
+ let resume_reason = winuser:: MsgWaitForMultipleObjectsEx (
485
485
0 ,
486
486
ptr:: null ( ) ,
487
- 1 ,
488
487
dur2timeout ( wait_until - now) . saturating_sub ( 1 ) ,
489
- winuser:: QS_ALLINPUT
488
+ winuser:: QS_ALLEVENTS ,
489
+ winuser:: MWMO_INPUTAVAILABLE
490
490
) ;
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
+ }
494
497
}
495
498
}
496
499
}
0 commit comments