mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Fix crash caused by WM_PAINT getting invoked at inopportune times. (#866)
This commit is contained in:
parent
d5391686ae
commit
6ff1370035
|
@ -21,6 +21,7 @@ fn main() {
|
|||
Event::NewEvents(StartCause::ResumeTimeReached{..}) => {
|
||||
*control_flow = ControlFlow::WaitUntil(Instant::now() + Duration::new(1, 0));
|
||||
println!("\nTimer\n");
|
||||
_window.set_inner_size(winit::dpi::LogicalSize::new(300.0, 300.0));
|
||||
},
|
||||
Event::WindowEvent {
|
||||
event: WindowEvent::CloseRequested,
|
||||
|
|
|
@ -839,6 +839,10 @@ unsafe extern "system" fn public_window_callback<T>(
|
|||
use event::WindowEvent::RedrawRequested;
|
||||
let mut runner = subclass_input.event_loop_runner.runner.borrow_mut();
|
||||
if let Some(ref mut runner) = *runner {
|
||||
// This check makes sure that calls to `request_redraw()` during `EventsCleared`
|
||||
// handling dispatch `RedrawRequested` immediately after `EventsCleared`, without
|
||||
// spinning up a new event loop iteration. We do this because that's what the API
|
||||
// says to do.
|
||||
match runner.runner_state {
|
||||
RunnerState::Idle(..) |
|
||||
RunnerState::DeferredNewEvents(..) => runner.call_event_handler(Event::WindowEvent {
|
||||
|
@ -852,25 +856,10 @@ unsafe extern "system" fn public_window_callback<T>(
|
|||
},
|
||||
winuser::WM_PAINT => {
|
||||
use event::WindowEvent::RedrawRequested;
|
||||
let event = || Event::WindowEvent {
|
||||
subclass_input.send_event(Event::WindowEvent {
|
||||
window_id: RootWindowId(WindowId(window)),
|
||||
event: RedrawRequested,
|
||||
};
|
||||
|
||||
let mut send_event = false;
|
||||
{
|
||||
let mut runner = subclass_input.event_loop_runner.runner.borrow_mut();
|
||||
if let Some(ref mut runner) = *runner {
|
||||
match runner.runner_state {
|
||||
RunnerState::Idle(..) |
|
||||
RunnerState::DeferredNewEvents(..) => runner.call_event_handler(event()),
|
||||
_ => send_event = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if send_event {
|
||||
subclass_input.send_event(event());
|
||||
}
|
||||
});
|
||||
commctrl::DefSubclassProc(window, msg, wparam, lparam)
|
||||
},
|
||||
|
||||
|
|
|
@ -730,7 +730,7 @@ unsafe fn init<T: 'static>(
|
|||
window_flags.set(WindowFlags::MAXIMIZED, attributes.maximized);
|
||||
|
||||
let window_state = {
|
||||
let mut window_state = WindowState::new(
|
||||
let window_state = WindowState::new(
|
||||
&attributes,
|
||||
window_icon,
|
||||
taskbar_icon,
|
||||
|
|
Loading…
Reference in a new issue