From 7601688a60bb137c1660389fc768457a43d46259 Mon Sep 17 00:00:00 2001 From: "U-ALDEBERAN\\Nate" Date: Sat, 28 Dec 2024 10:08:10 -0500 Subject: [PATCH] ChangeLog: Creating an API to enable creating winit Windows with Slint's event loop In `winit`, it is not possible to instantiate a new window without access to the `winit` event loop, which Slint manages. With this change, there is now a `create_winit_window` call on Slint's winit` back end that will enable creating `winit` windows using existing functionality. Of course, the utility of these windows is limited without access to `winit` event handling, but there are applications for which simply creating a window and instructing an external program to write into it (by passing the `HWND` on Windows or the `XId` on X11) is useful. --- internal/backends/winit/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/backends/winit/lib.rs b/internal/backends/winit/lib.rs index 739a7011ae4..7acab86447c 100644 --- a/internal/backends/winit/lib.rs +++ b/internal/backends/winit/lib.rs @@ -596,6 +596,13 @@ impl WinitWindowAccessor for i_slint_core::api::Window { impl private::WinitWindowAccessorSealed for i_slint_core::api::Window {} +/// Creates a non Slint aware window with winit +pub fn create_winit_window( + window_attributes: winit::window::WindowAttributes, +) -> Result { + event_loop::with_window_target(|eli| Ok(eli.create_window(window_attributes))).unwrap() +} + #[cfg(test)] mod testui { slint::slint! {