@@ -3,7 +3,9 @@ use bevy_ecs::entity::Entity;
33
44use bevy_ecs:: entity:: EntityHashMap ;
55use bevy_utils:: { tracing:: warn, HashMap } ;
6- use bevy_window:: { CursorGrabMode , Window , WindowMode , WindowPosition , WindowResolution } ;
6+ use bevy_window:: {
7+ CursorGrabMode , Window , WindowMode , WindowPosition , WindowResolution , WindowWrapper ,
8+ } ;
79
810use winit:: {
911 dpi:: { LogicalSize , PhysicalPosition } ,
@@ -20,7 +22,7 @@ use crate::{
2022#[ derive( Debug , Default ) ]
2123pub struct WinitWindows {
2224 /// Stores [`winit`] windows by window identifier.
23- pub windows : HashMap < winit:: window:: WindowId , winit:: window:: Window > ,
25+ pub windows : HashMap < winit:: window:: WindowId , WindowWrapper < winit:: window:: Window > > ,
2426 /// Maps entities to `winit` window identifiers.
2527 pub entity_to_winit : EntityHashMap < winit:: window:: WindowId > ,
2628 /// Maps `winit` window identifiers to entities.
@@ -41,7 +43,7 @@ impl WinitWindows {
4143 adapters : & mut AccessKitAdapters ,
4244 handlers : & mut WinitActionHandlers ,
4345 accessibility_requested : & AccessibilityRequested ,
44- ) -> & winit:: window:: Window {
46+ ) -> & WindowWrapper < winit:: window:: Window > {
4547 let mut winit_window_builder = winit:: window:: WindowBuilder :: new ( ) ;
4648
4749 // Due to a UIA limitation, winit windows need to be invisible for the
@@ -240,12 +242,12 @@ impl WinitWindows {
240242
241243 self . windows
242244 . entry ( winit_window. id ( ) )
243- . insert ( winit_window)
245+ . insert ( WindowWrapper :: new ( winit_window) )
244246 . into_mut ( )
245247 }
246248
247249 /// Get the winit window that is associated with our entity.
248- pub fn get_window ( & self , entity : Entity ) -> Option < & winit:: window:: Window > {
250+ pub fn get_window ( & self , entity : Entity ) -> Option < & WindowWrapper < winit:: window:: Window > > {
249251 self . entity_to_winit
250252 . get ( & entity)
251253 . and_then ( |winit_id| self . windows . get ( winit_id) )
@@ -261,7 +263,10 @@ impl WinitWindows {
261263 /// Remove a window from winit.
262264 ///
263265 /// This should mostly just be called when the window is closing.
264- pub fn remove_window ( & mut self , entity : Entity ) -> Option < winit:: window:: Window > {
266+ pub fn remove_window (
267+ & mut self ,
268+ entity : Entity ,
269+ ) -> Option < WindowWrapper < winit:: window:: Window > > {
265270 let winit_id = self . entity_to_winit . remove ( & entity) ?;
266271 self . winit_to_entity . remove ( & winit_id) ;
267272 self . windows . remove ( & winit_id)
0 commit comments