diff --git a/internal/backends/winit/lib.rs b/internal/backends/winit/lib.rs index 2dbade472..a3540efd0 100644 --- a/internal/backends/winit/lib.rs +++ b/internal/backends/winit/lib.rs @@ -645,6 +645,12 @@ pub trait WinitWindowAccessor: private::WinitWindowAccessorSealed { callback: impl FnMut(&i_slint_core::api::Window, &winit::event::WindowEvent) -> WinitWindowEventResult + 'static, ); + + /// Creates a non Slint aware window with winit + fn create_winit_window( + &self, + window_attributes: winit::window::WindowAttributes, + ) -> Result; } impl WinitWindowAccessor for i_slint_core::api::Window { @@ -682,6 +688,23 @@ impl WinitWindowAccessor for i_slint_core::api::Window { .set(Some(Box::new(move |window, event| callback(window, event)))); } } + + /// Creates a non Slint aware window with winit + fn create_winit_window( + &self, + window_attributes: winit::window::WindowAttributes, + ) -> Result { + i_slint_core::window::WindowInner::from_pub(self) + .window_adapter() + .internal(i_slint_core::InternalToken) + .unwrap() + .as_any() + .downcast_ref::() + .unwrap() + .shared_backend_data + .with_event_loop(|eli| Ok(eli.create_window(window_attributes))) + .unwrap() + } } impl private::WinitWindowAccessorSealed for i_slint_core::api::Window {} diff --git a/internal/backends/winit/winitwindowadapter.rs b/internal/backends/winit/winitwindowadapter.rs index 24aec9b69..327d4bba9 100644 --- a/internal/backends/winit/winitwindowadapter.rs +++ b/internal/backends/winit/winitwindowadapter.rs @@ -246,7 +246,7 @@ impl WinitWindowOrNone { /// GraphicsWindow is an implementation of the [WindowAdapter][`crate::eventloop::WindowAdapter`] trait. This is /// typically instantiated by entry factory functions of the different graphics back ends. pub struct WinitWindowAdapter { - shared_backend_data: Rc, + pub shared_backend_data: Rc, window: OnceCell, self_weak: Weak, pending_redraw: Cell,