From 6bae3e7507a3162f538c15c82bf3730301da2cd5 Mon Sep 17 00:00:00 2001 From: Billy Messenger Date: Sat, 17 Oct 2020 16:47:36 -0500 Subject: [PATCH] Fix window_state pointer --- src/win/window.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/win/window.rs b/src/win/window.rs index aaa758b..872f751 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -82,9 +82,7 @@ unsafe extern "system" fn wnd_proc( let mut window_state = window_state.borrow_mut(); - // FIXME: For some reason, the data in window_info is corrupted. - // let logical_pos = window_state.window_info.physical_to_logical(physical_pos); - let logical_pos = physical_pos; + let logical_pos = window_state.window_info.physical_to_logical(physical_pos); window_state.handler.on_event( &mut window, @@ -242,15 +240,13 @@ impl Window { let handler = H::build(&mut window); - let window_state = Rc::new(RefCell::new(WindowState { + let window_state = Box::new(RefCell::new(WindowState { window_class, window_info, handler, })); - let win = Rc::new(RefCell::new(window)); - - SetWindowLongPtrA(hwnd, GWLP_USERDATA, Rc::into_raw(win) as *const _ as _); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, Box::into_raw(window_state) as *const _ as _); SetTimer(hwnd, 4242, 13, None); Ok((WindowHandle { hwnd }, window_info))