Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed forced modal pause of the application when resizing or moving on Windows #415

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/native/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub(crate) struct WindowsDisplay {
wnd: HWND,
dc: HDC,
event_handler: Option<Box<dyn EventHandler>>,
modal_resizing_timer: usize,
}

impl WindowsDisplay {
Expand Down Expand Up @@ -461,7 +462,37 @@ unsafe extern "system" fn win32_wndproc(
let mods = key_mods();
event_handler.key_up_event(keycode, mods);
}
WM_ENTERSIZEMOVE | WM_ENTERMENULOOP => {
SetTimer(
hwnd,
&mut payload.modal_resizing_timer as *mut _ as usize,
10,
None,
);
}
WM_TIMER => {
if wparam == &mut payload.modal_resizing_timer as *mut _ as usize {
payload.event_handler.as_mut().unwrap().update();
payload.event_handler.as_mut().unwrap().draw();

SwapBuffers(payload.dc);

if payload.update_dimensions(hwnd) {
let d = crate::native_display().lock().unwrap();
let width = d.screen_width as f32;
let height = d.screen_height as f32;
drop(d);
payload
.event_handler
.as_mut()
.unwrap()
.resize_event(width, height);
}
}
}
WM_EXITSIZEMOVE | WM_EXITMENULOOP => {
KillTimer(hwnd, &mut payload.modal_resizing_timer as *mut _ as usize);
}
_ => {}
}

Expand Down Expand Up @@ -812,6 +843,7 @@ where
wnd,
dc,
event_handler: None,
modal_resizing_timer: 0,
};

let (tx, rx) = std::sync::mpsc::channel();
Expand Down
Loading