@@ -37,7 +37,7 @@ use winapi::shared::minwindef::{
3737 WPARAM ,
3838} ;
3939use winapi:: shared:: windef:: { HWND , POINT , RECT } ;
40- use winapi:: shared:: windowsx;
40+ use winapi:: shared:: { windowsx, winerror } ;
4141use winapi:: um:: { winuser, winbase, ole2, processthreadsapi, commctrl, libloaderapi} ;
4242use 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