mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-11 13:31:29 +11:00
Windows: Fix set_cursor delay (#660)
This commit is contained in:
parent
b0e3865562
commit
808638fee3
|
@ -7,6 +7,7 @@
|
|||
- Updated window manager hints under X11 to v1.5 of [Extended Window Manager Hints](https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm140200472629520).
|
||||
- Added `WindowBuilderExt::with_gtk_theme_variant` to X11-specific `WindowBuilder` functions.
|
||||
- Fixed UTF8 handling bug in X11 `set_title` function.
|
||||
- On Windows, `Window::set_cursor` now applies immediately instead of requiring specific events to occur first.
|
||||
|
||||
# Version 0.17.2 (2018-08-19)
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ unsafe impl Send for PlatformSpecificWindowBuilderAttributes {}
|
|||
unsafe impl Sync for PlatformSpecificWindowBuilderAttributes {}
|
||||
|
||||
// Cursor name in UTF-16. Used to set cursor in `WM_SETCURSOR`.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Cursor(pub *const winapi::ctypes::wchar_t);
|
||||
unsafe impl Send for Cursor {}
|
||||
unsafe impl Sync for Cursor {}
|
||||
|
|
|
@ -301,7 +301,7 @@ impl Window {
|
|||
|
||||
#[inline]
|
||||
pub fn set_cursor(&self, cursor: MouseCursor) {
|
||||
let cursor_id = match cursor {
|
||||
let cursor_id = Cursor(match cursor {
|
||||
MouseCursor::Arrow | MouseCursor::Default => winuser::IDC_ARROW,
|
||||
MouseCursor::Hand => winuser::IDC_HAND,
|
||||
MouseCursor::Crosshair => winuser::IDC_CROSS,
|
||||
|
@ -321,10 +321,15 @@ impl Window {
|
|||
MouseCursor::Progress => winuser::IDC_APPSTARTING,
|
||||
MouseCursor::Help => winuser::IDC_HELP,
|
||||
_ => winuser::IDC_ARROW, // use arrow for the missing cases.
|
||||
};
|
||||
|
||||
let mut cur = self.window_state.lock().unwrap();
|
||||
cur.cursor = Cursor(cursor_id);
|
||||
});
|
||||
self.window_state.lock().unwrap().cursor = cursor_id;
|
||||
self.events_loop_proxy.execute_in_thread(move |_| unsafe {
|
||||
let cursor = winuser::LoadCursorW(
|
||||
ptr::null_mut(),
|
||||
cursor_id.0,
|
||||
);
|
||||
winuser::SetCursor(cursor);
|
||||
});
|
||||
}
|
||||
|
||||
unsafe fn cursor_is_grabbed(&self) -> Result<bool, String> {
|
||||
|
|
Loading…
Reference in a new issue