Skip to content

Commit

Permalink
update windows backend
Browse files Browse the repository at this point in the history
  • Loading branch information
micahrj committed Dec 17, 2023
1 parent f2882d2 commit eb2cb60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
3 changes: 1 addition & 2 deletions src/win/drop_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ impl DropTarget {
};

unsafe {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

let event = Event::Mouse(event);
let event_status =
Expand Down
24 changes: 8 additions & 16 deletions src/win/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ unsafe fn wnd_proc_inner(
) -> Option<LRESULT> {
match msg {
WM_MOUSEMOVE => {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

let x = (lparam & 0xFFFF) as i16 as i32;
let y = ((lparam >> 16) & 0xFFFF) as i16 as i32;
Expand All @@ -197,8 +196,7 @@ unsafe fn wnd_proc_inner(
Some(0)
}
WM_MOUSEWHEEL | WM_MOUSEHWHEEL => {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

let value = (wparam >> 16) as i16;
let value = value as i32;
Expand All @@ -222,8 +220,7 @@ unsafe fn wnd_proc_inner(
}
WM_LBUTTONDOWN | WM_LBUTTONUP | WM_MBUTTONDOWN | WM_MBUTTONUP | WM_RBUTTONDOWN
| WM_RBUTTONUP | WM_XBUTTONDOWN | WM_XBUTTONUP => {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

let mut mouse_button_counter = window_state.mouse_button_counter.get();

Expand Down Expand Up @@ -286,8 +283,7 @@ unsafe fn wnd_proc_inner(
None
}
WM_TIMER => {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

if wparam == WIN_FRAME_TIMER {
window_state.handler.borrow_mut().as_mut().unwrap().on_frame(&mut window);
Expand All @@ -298,8 +294,7 @@ unsafe fn wnd_proc_inner(
WM_CLOSE => {
// Make sure to release the borrow before the DefWindowProc call
{
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

window_state
.handler
Expand All @@ -315,8 +310,7 @@ unsafe fn wnd_proc_inner(
}
WM_CHAR | WM_SYSCHAR | WM_KEYDOWN | WM_SYSKEYDOWN | WM_KEYUP | WM_SYSKEYUP
| WM_INPUTLANGCHANGE => {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

let opt_event =
window_state.keyboard_state.borrow_mut().process_message(hwnd, msg, wparam, lparam);
Expand All @@ -337,8 +331,7 @@ unsafe fn wnd_proc_inner(
}
}
WM_SIZE => {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

let width = (lparam & 0xFFFF) as u16 as u32;
let height = ((lparam >> 16) & 0xFFFF) as u16 as u32;
Expand Down Expand Up @@ -684,8 +677,7 @@ impl Window<'_> {
});

let handler = {
let mut window = window_state.create_window();
let mut window = crate::Window::new(&mut window);
let mut window = crate::Window::new(window_state.create_window());

build(&mut window)
};
Expand Down

0 comments on commit eb2cb60

Please sign in to comment.