Allow custom cursor caching (#3276)

This commit is contained in:
daxpedda 2023-12-22 22:20:41 +01:00 committed by GitHub
parent 0a7ea61834
commit 2c15de7cf9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 579 additions and 347 deletions

View file

@ -17,6 +17,7 @@ pub(crate) use self::{
pub use self::icon::WinIcon as PlatformIcon;
pub(crate) use crate::cursor::CursorImage as PlatformCustomCursor;
pub(crate) use crate::cursor::CursorImage as PlatformCustomCursorBuilder;
use crate::platform_impl::Fullscreen;
use crate::event::DeviceId as RootDeviceId;

View file

@ -55,7 +55,6 @@ use windows_sys::Win32::{
};
use crate::{
cursor::CustomCursor,
dpi::{PhysicalPosition, PhysicalSize, Position, Size},
error::{ExternalError, NotSupportedError, OsError as RootOsError},
icon::Icon,
@ -73,7 +72,8 @@ use crate::{
monitor::{self, MonitorHandle},
util,
window_state::{CursorFlags, SavedWindow, WindowFlags, WindowState},
Fullscreen, PlatformSpecificWindowBuilderAttributes, SelectedCursor, WindowId,
Fullscreen, PlatformCustomCursor, PlatformSpecificWindowBuilderAttributes, SelectedCursor,
WindowId,
},
window::{
CursorGrabMode, CursorIcon, ImePurpose, ResizeDirection, Theme, UserAttentionType,
@ -405,8 +405,8 @@ impl Window {
}
#[inline]
pub fn set_custom_cursor(&self, cursor: CustomCursor) {
let new_cursor = match WinCursor::new(&cursor.inner) {
pub(crate) fn set_custom_cursor(&self, cursor: Arc<PlatformCustomCursor>) {
let new_cursor = match WinCursor::new(&cursor) {
Ok(cursor) => cursor,
Err(err) => {
warn!("Failed to create custom cursor: {err}");