Windows: CursorState improvements (#526)
* Windows: CursorState improvements Fixes #523 Prior to changing the cursor state, we now check the current grab state, since it can be invalidated by alt-tabbing and other things. `CursorState::Hide` is also implemented now. The cursor name is now wrapped in a `Cursor` struct to allow multithreaded access. `Window::set_cursor_state` has been reworked to use `execute_in_thread`. Two unneeded `transmute` calls were also removed. The `WM_SETCURSOR` handler is much more readable now. `MonitorId::get_adapter_name` has been removed, since it's dead code and appears to be a relic from 4 years ago. * Windows: CursorState::Grab no longer hides cursor `MouseCursor::NoneCursor` has been implemented to allow for equivalent behavior to the older implementation. Windows and X11 now have consistent cursor grabbing behavior. macOS still needs to be updated. * Windows: Grabbing auto-hides again (for now) This API needs more work, so let's stick to a bug fix and some refactoring. However, it now hides using a different technique than it did originally, which applies instantly instead of after mouse movement.
This commit is contained in:
parent
fddfb2e2d6
commit
f6d26df64d
6 changed files with 125 additions and 83 deletions
|
|
@ -3,6 +3,7 @@ use std::ops::BitAnd;
|
|||
|
||||
use winapi::ctypes::wchar_t;
|
||||
use winapi::shared::minwindef::DWORD;
|
||||
use winapi::shared::windef::RECT;
|
||||
use winapi::um::errhandlingapi::GetLastError;
|
||||
use winapi::um::winbase::{
|
||||
FormatMessageW,
|
||||
|
|
@ -32,6 +33,15 @@ pub fn wchar_to_string(wchar: &[wchar_t]) -> String {
|
|||
.to_string()
|
||||
}
|
||||
|
||||
// This won't be needed anymore if we just add a derive to winapi.
|
||||
pub fn rect_eq(a: &RECT, b: &RECT) -> bool {
|
||||
let left_eq = a.left == b.left;
|
||||
let right_eq = a.right == b.right;
|
||||
let top_eq = a.top == b.top;
|
||||
let bottom_eq = a.bottom == b.bottom;
|
||||
left_eq && right_eq && top_eq && bottom_eq
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
||||
pub struct WinError(Option<String>);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue