@@ -149,6 +149,8 @@ pub struct CustomCursorCache(pub HashMap<CustomCursorCacheKey, winit::window::Cu
149
149
/// A source for a cursor. Is created in `bevy_render` and consumed by the winit event loop.
150
150
#[ derive( Debug ) ]
151
151
pub enum CursorSource {
152
+ /// Cursor was set to hidden, so we need to pass this onto the winit_window
153
+ Hidden ,
152
154
/// A custom cursor was identified to be cached, no reason to recreate it.
153
155
CustomCached ( CustomCursorCacheKey ) ,
154
156
/// A custom cursor was not cached, so it needs to be created by the winit event loop.
@@ -795,22 +797,28 @@ impl<T: Event> WinitAppRunnerState<T> {
795
797
continue ;
796
798
} ;
797
799
798
- let final_cursor: winit:: window:: Cursor = match pending_cursor {
800
+ let final_cursor: Option < winit:: window:: Cursor > = match pending_cursor {
801
+ CursorSource :: Hidden => None ,
799
802
CursorSource :: CustomCached ( cache_key) => {
800
803
let Some ( cached_cursor) = cursor_cache. 0 . get ( & cache_key) else {
801
804
error ! ( "Cursor should have been cached, but was not found" ) ;
802
805
continue ;
803
806
} ;
804
- cached_cursor. clone ( ) . into ( )
807
+ Some ( cached_cursor. clone ( ) . into ( ) )
805
808
}
806
809
CursorSource :: Custom ( ( cache_key, cursor) ) => {
807
810
let custom_cursor = event_loop. create_custom_cursor ( cursor) ;
808
811
cursor_cache. 0 . insert ( cache_key, custom_cursor. clone ( ) ) ;
809
- custom_cursor. into ( )
812
+ Some ( custom_cursor. into ( ) )
810
813
}
811
- CursorSource :: System ( system_cursor) => system_cursor. into ( ) ,
814
+ CursorSource :: System ( system_cursor) => Some ( system_cursor. into ( ) ) ,
812
815
} ;
813
- winit_window. set_cursor ( final_cursor) ;
816
+ if let Some ( final_cursor) = final_cursor {
817
+ winit_window. set_cursor_visible ( true ) ;
818
+ winit_window. set_cursor ( final_cursor) ;
819
+ } else {
820
+ winit_window. set_cursor_visible ( false ) ;
821
+ }
814
822
}
815
823
}
816
824
}
0 commit comments