From 7289b6091b61b0aa448a756cfe32211c78a4cce0 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 9 Jan 2024 07:19:15 -0800 Subject: WIP raw-window-handle 0.6 --- winit/src/application.rs | 24 ++++++++++++++---------- winit/src/clipboard.rs | 3 ++- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index bf48538d..d639a36b 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -24,6 +24,7 @@ use crate::{Clipboard, Error, Proxy, Settings}; use futures::channel::mpsc; use std::mem::ManuallyDrop; +use std::sync::Arc; /// An interactive, native cross-platform application. /// @@ -105,7 +106,7 @@ pub fn run( where A: Application + 'static, E: Executor + 'static, - C: Compositor + 'static, + C: Compositor, Renderer = A::Renderer> + 'static, ::Theme: StyleSheet, { use futures::task; @@ -149,9 +150,12 @@ where log::debug!("Window builder: {builder:#?}"); - let window = builder - .build(&event_loop) - .map_err(Error::WindowCreationFailed)?; + // XXX Arc? + let window = Arc::new( + builder + .build(&event_loop) + .map_err(Error::WindowCreationFailed)?, + ); #[cfg(target_arch = "wasm32")] { @@ -183,7 +187,7 @@ where }; } - let compositor = C::new(compositor_settings, Some(&window))?; + let compositor = C::new(compositor_settings, Some(window.clone()))?; let mut renderer = compositor.create_renderer(); for font in settings.fonts { @@ -248,13 +252,13 @@ async fn run_instance( >, mut control_sender: mpsc::UnboundedSender, init_command: Command, - window: winit::window::Window, + window: Arc, should_be_visible: bool, exit_on_close_request: bool, ) where A: Application + 'static, E: Executor + 'static, - C: Compositor + 'static, + C: Compositor, Renderer = A::Renderer> + 'static, ::Theme: StyleSheet, { use futures::stream::StreamExt; @@ -268,7 +272,7 @@ async fn run_instance( let mut clipboard = Clipboard::connect(&window); let mut cache = user_interface::Cache::default(); let mut surface = compositor.create_surface( - &window, + window.clone(), physical_size.width, physical_size.height, ); @@ -608,7 +612,7 @@ pub fn update( messages: &mut Vec, window: &winit::window::Window, ) where - C: Compositor + 'static, + C: Compositor, Renderer = A::Renderer> + 'static, ::Theme: StyleSheet, { for message in messages.drain(..) { @@ -659,7 +663,7 @@ pub fn run_command( ) where A: Application, E: Executor, - C: Compositor + 'static, + C: Compositor, Renderer = A::Renderer> + 'static, ::Theme: StyleSheet, { use crate::runtime::command; diff --git a/winit/src/clipboard.rs b/winit/src/clipboard.rs index f7a32868..8f5c5e63 100644 --- a/winit/src/clipboard.rs +++ b/winit/src/clipboard.rs @@ -15,7 +15,8 @@ enum State { impl Clipboard { /// Creates a new [`Clipboard`] for the given window. pub fn connect(window: &winit::window::Window) -> Clipboard { - let state = window_clipboard::Clipboard::connect(window) + #[allow(unsafe_code)] + let state = unsafe { window_clipboard::Clipboard::connect(window) } .ok() .map(State::Connected) .unwrap_or(State::Unavailable); -- cgit