Skip to content

Commit

Permalink
Fix bugs filnet discovered in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Osspial committed Mar 6, 2020
1 parent d46f701 commit 6579977
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
6 changes: 2 additions & 4 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ unsafe fn flush_paint_messages<T: 'static>(except: Option<HWND>, runner: &ELRSha
redraw_window,
winuser::WM_PAINT,
winuser::WM_PAINT,
winuser::PM_REMOVE | winuser::QS_PAINT,
winuser::PM_REMOVE | winuser::PM_QS_PAINT,
) {
return;
}
Expand Down Expand Up @@ -1817,8 +1817,6 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
// Because WM_PAINT comes after all other messages, we use it during modal loops to detect
// when the event queue has been emptied. See `process_event` for more details.
winuser::WM_PAINT => {
winuser::ValidateRect(window, ptr::null());

// If the WM_PAINT handler in `public_window_callback` has already flushed the redraw
// events, `handling_events` will return false and we won't emit a second
// `RedrawEventsCleared` event.
Expand All @@ -1833,7 +1831,7 @@ unsafe extern "system" fn thread_event_target_callback<T: 'static>(
process_control_flow(&subclass_input.event_loop_runner);
}

0
commctrl::DefSubclassProc(window, msg, wparam, lparam)
}

winuser::WM_INPUT_DEVICE_CHANGE => {
Expand Down
29 changes: 20 additions & 9 deletions src/platform_impl/windows/event_loop/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,14 @@ impl<T> ELRShared<T> {

(Uninitialized, MainEvents) => {
self.call_new_events(true);
self.call_event_handler(Event::NewEvents(StartCause::Init));
}
(Uninitialized, RedrawEvents) => {
self.call_new_events(true);
self.call_event_handler(Event::MainEventsCleared);
self.call_events_cleared();
}
(Uninitialized, NoEvents) => {
self.call_new_events(true);
self.call_event_handler(Event::MainEventsCleared);
self.call_events_cleared();
self.call_event_handler(Event::RedrawEventsCleared);
}
(_, Uninitialized) => panic!("cannot move state to Uninitialized"),
Expand All @@ -282,14 +281,14 @@ impl<T> ELRShared<T> {
}
(NoEvents, RedrawEvents) => {
self.call_new_events(false);
self.call_event_handler(Event::MainEventsCleared);
self.call_events_cleared();
}
(MainEvents, RedrawEvents) => {
self.call_event_handler(Event::MainEventsCleared);
self.call_events_cleared();
}
(MainEvents, NoEvents) => {
warn!("RedrawEventsCleared emitted without explicit MainEventsCleared");
self.call_event_handler(Event::MainEventsCleared);
self.call_events_cleared();
self.call_event_handler(Event::RedrawEventsCleared);
}
(RedrawEvents, NoEvents) => {
Expand All @@ -311,9 +310,16 @@ impl<T> ELRShared<T> {
requested_resume: None,
start: self.last_events_cleared.get(),
},
(false, ControlFlow::WaitUntil(requested_resume)) => StartCause::WaitCancelled {
requested_resume: Some(requested_resume),
start: self.last_events_cleared.get(),
(false, ControlFlow::WaitUntil(requested_resume)) => if Instant::now() < requested_resume {
StartCause::WaitCancelled {
requested_resume: Some(requested_resume),
start: self.last_events_cleared.get(),
}
} else {
StartCause::ResumeTimeReached{
requested_resume: requested_resume,
start: self.last_events_cleared.get(),
}
},
};
self.call_event_handler(Event::NewEvents(start_cause));
Expand All @@ -325,4 +331,9 @@ impl<T> ELRShared<T> {
winuser::RDW_INTERNALPAINT,
);
}

unsafe fn call_events_cleared(&self) {
self.last_events_cleared.set(Instant::now());
self.call_event_handler(Event::MainEventsCleared);
}
}

0 comments on commit 6579977

Please sign in to comment.