Skip to content

Commit

Permalink
On Windows, move modal loop jumpstart to set_modal_loop() method
Browse files Browse the repository at this point in the history
This fixes a panic.
Note that the WM_PAINT event is now sent to the modal_redraw_method
which is more correct and avoids an unecessary redraw of the window.

Relates to but does does not fix #1484
  • Loading branch information
Philippe Renon committed Feb 27, 2020
1 parent 7174687 commit 19e2307
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 0 additions & 7 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,6 @@ unsafe extern "system" fn public_window_callback<T: 'static>(
}

winuser::WM_NCLBUTTONDOWN => {
// jumpstart the modal loop
winuser::RedrawWindow(
window,
ptr::null(),
ptr::null_mut(),
winuser::RDW_INTERNALPAINT,
);
if wparam == winuser::HTCAPTION as _ {
winuser::PostMessageW(window, winuser::WM_MOUSEMOVE, 0, 0);
}
Expand Down
13 changes: 12 additions & 1 deletion src/platform_impl/windows/event_loop/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<T> ELRShared<T> {
if let Err(event) = self.send_event_unbuffered(event) {
// If the runner is already borrowed, we're in the middle of an event loop invocation.
// Add the event to a buffer to be processed later.
if let Event::RedrawRequested(_) = event {
if let Event::RedrawRequested(_) = event {
panic!("buffering RedrawRequested event");
}
self.buffer
Expand Down Expand Up @@ -178,6 +178,17 @@ impl<T> ELRShared<T> {
let mut runner_ref = self.runner.borrow_mut();
if let Some(ref mut runner) = *runner_ref {
runner.in_modal_loop = in_modal_loop;
if in_modal_loop {
// jumpstart the modal loop
unsafe {
winuser::RedrawWindow(
runner.modal_redraw_window,
ptr::null(),
ptr::null_mut(),
winuser::RDW_INTERNALPAINT,
);
}
}
}
}

Expand Down

0 comments on commit 19e2307

Please sign in to comment.