From 2faea075b163b7a45f83c8de66fa4b589e088f63 Mon Sep 17 00:00:00 2001 From: Micah Johnston Date: Mon, 7 Dec 2020 00:42:55 -0600 Subject: [PATCH] call on_frame on WM_TIMER events --- src/win/window.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/win/window.rs b/src/win/window.rs index 1318755..bfa7308 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -60,13 +60,6 @@ unsafe fn generate_guid() -> String { const WIN_FRAME_TIMER: usize = 4242; -unsafe fn handle_timer(window_state: &RefCell>, timer_id: usize) { - match timer_id { - WIN_FRAME_TIMER => {} - _ => (), - } -} - unsafe extern "system" fn wnd_proc( hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM, ) -> LRESULT { @@ -133,7 +126,12 @@ unsafe extern "system" fn wnd_proc( } } WM_TIMER => { - handle_timer(&window_state, wparam); + match wparam { + WIN_FRAME_TIMER => { + window_state.borrow_mut().handler.on_frame(); + } + _ => (), + } return 0; } WM_CLOSE => { @@ -320,7 +318,7 @@ impl Window { })); 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 { phantom_data: std::marker::PhantomData,