From ec41918ec40bddaba81235372f1566da59fd09f2 Mon Sep 17 00:00:00 2001 From: bungoboingo Date: Thu, 5 Jan 2023 15:26:28 -0800 Subject: Implemented window title update functionality for multiwindow. --- glutin/src/application.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 45ff37f0..f43a47b9 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -245,18 +245,7 @@ where ) })?; - let (width, height) = window.inner_size().into(); - let surface_attributes = - SurfaceAttributesBuilder::::new() - .with_srgb(Some(true)) - .build( - window_handle, - NonZeroU32::new(width).unwrap_or(ONE), - NonZeroU32::new(height).unwrap_or(ONE), - ); - - let surface = display - .create_window_surface(configuration.as_ref(), &surface_attributes) + let surface = gl_surface(&display, configuration.as_ref(), &window) .map_err(|error| { Error::GraphicsCreationFailed( iced_graphics::Error::BackendError(format!( @@ -616,3 +605,23 @@ async fn run_instance( // Manually drop the user interface drop(ManuallyDrop::into_inner(user_interface)); } + +#[allow(unsafe_code)] +/// Creates a new [`glutin::Surface`]. +pub fn gl_surface( + display: &Display, + gl_config: &Config, + window: &winit::window::Window, +) -> Result, glutin::error::Error> { + let (width, height) = window.inner_size().into(); + + let surface_attributes = SurfaceAttributesBuilder::::new() + .with_srgb(Some(true)) + .build( + window.raw_window_handle(), + NonZeroU32::new(width).unwrap_or(ONE), + NonZeroU32::new(height).unwrap_or(ONE), + ); + + unsafe { display.create_window_surface(gl_config, &surface_attributes) } +} -- cgit