1
0
Fork 0

Fix window_state pointer

This commit is contained in:
Billy Messenger 2020-10-17 16:47:36 -05:00
parent 5866bf372e
commit 6bae3e7507

View file

@ -82,9 +82,7 @@ unsafe extern "system" fn wnd_proc<H: WindowHandler>(
let mut window_state = window_state.borrow_mut(); 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 = window_state.window_info.physical_to_logical(physical_pos);
let logical_pos = physical_pos;
window_state.handler.on_event( window_state.handler.on_event(
&mut window, &mut window,
@ -242,15 +240,13 @@ impl Window {
let handler = H::build(&mut 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_class,
window_info, window_info,
handler, handler,
})); }));
let win = Rc::new(RefCell::new(window)); SetWindowLongPtrA(hwnd, GWLP_USERDATA, Box::into_raw(window_state) as *const _ as _);
SetWindowLongPtrA(hwnd, GWLP_USERDATA, Rc::into_raw(win) as *const _ as _);
SetTimer(hwnd, 4242, 13, None); SetTimer(hwnd, 4242, 13, None);
Ok((WindowHandle { hwnd }, window_info)) Ok((WindowHandle { hwnd }, window_info))