mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
More work on win32 implementation
This commit is contained in:
parent
bb418efcc7
commit
bae1e42b8b
2 changed files with 16 additions and 2 deletions
|
@ -42,6 +42,11 @@ fn main() {
|
||||||
.ok().expect("could not grab mouse cursor");
|
.ok().expect("could not grab mouse cursor");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
a @ Event::MouseMoved(_) => {
|
||||||
|
println!("{:?}", a);
|
||||||
|
},
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,12 @@ impl Window {
|
||||||
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> {
|
||||||
let mut current_state = self.cursor_state.lock().unwrap();
|
let mut current_state = self.cursor_state.lock().unwrap();
|
||||||
|
|
||||||
match (state, *current_state) {
|
let foreground_thread_id = unsafe { user32::GetWindowThreadProcessId(self.window.0, ptr::null_mut()) };
|
||||||
|
let current_thread_id = unsafe { kernel32::GetCurrentThreadId() };
|
||||||
|
|
||||||
|
unsafe { user32::AttachThreadInput(foreground_thread_id, current_thread_id, 1) };
|
||||||
|
|
||||||
|
let res = match (state, *current_state) {
|
||||||
(CursorState::Normal, CursorState::Normal) => Ok(()),
|
(CursorState::Normal, CursorState::Normal) => Ok(()),
|
||||||
(CursorState::Hide, CursorState::Hide) => Ok(()),
|
(CursorState::Hide, CursorState::Hide) => Ok(()),
|
||||||
(CursorState::Grab, CursorState::Grab) => Ok(()),
|
(CursorState::Grab, CursorState::Grab) => Ok(()),
|
||||||
|
@ -310,7 +315,11 @@ impl Window {
|
||||||
},
|
},
|
||||||
|
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
};
|
||||||
|
|
||||||
|
unsafe { user32::AttachThreadInput(foreground_thread_id, current_thread_id, 0) };
|
||||||
|
|
||||||
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hidpi_factor(&self) -> f32 {
|
pub fn hidpi_factor(&self) -> f32 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue