1
0
Fork 0

call on_frame on WM_TIMER events

This commit is contained in:
Micah Johnston 2020-12-07 00:42:55 -06:00 committed by glowcoil
parent 365cc8c018
commit 2faea075b1

View file

@ -60,13 +60,6 @@ unsafe fn generate_guid() -> String {
const WIN_FRAME_TIMER: usize = 4242; const WIN_FRAME_TIMER: usize = 4242;
unsafe fn handle_timer<H: WindowHandler>(window_state: &RefCell<WindowState<H>>, timer_id: usize) {
match timer_id {
WIN_FRAME_TIMER => {}
_ => (),
}
}
unsafe extern "system" fn wnd_proc<H: WindowHandler>( unsafe extern "system" fn wnd_proc<H: WindowHandler>(
hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM, hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM,
) -> LRESULT { ) -> LRESULT {
@ -133,7 +126,12 @@ unsafe extern "system" fn wnd_proc<H: WindowHandler>(
} }
} }
WM_TIMER => { WM_TIMER => {
handle_timer(&window_state, wparam); match wparam {
WIN_FRAME_TIMER => {
window_state.borrow_mut().handler.on_frame();
}
_ => (),
}
return 0; return 0;
} }
WM_CLOSE => { WM_CLOSE => {
@ -320,7 +318,7 @@ impl Window {
})); }));
SetWindowLongPtrA(hwnd, GWLP_USERDATA, Box::into_raw(window_state) as *const _ as _); SetWindowLongPtrA(hwnd, GWLP_USERDATA, Box::into_raw(window_state) as *const _ as _);
SetTimer(hwnd, 4242, 13, None); SetTimer(hwnd, WIN_FRAME_TIMER, 15, None);
let window_handle = crate::WindowHandle(WindowHandle { let window_handle = crate::WindowHandle(WindowHandle {
phantom_data: std::marker::PhantomData, phantom_data: std::marker::PhantomData,