diff --git a/examples/cursors/src/main.rs b/examples/cursors/src/main.rs index 900ff2f8..a0a3087f 100644 --- a/examples/cursors/src/main.rs +++ b/examples/cursors/src/main.rs @@ -99,6 +99,6 @@ fn main() -> Result<(), baseview::Error> { .with_size(LogicalSize::new(512, 512)) .with_gl_config(GlConfig::default()); - Window::create(window_open_options, CursorsExample::new)?.run_until_closed()?; + Window::create(window_open_options, None, CursorsExample::new)?.run_until_closed()?; Ok(()) } diff --git a/examples/external-wakeup/src/main.rs b/examples/external-wakeup/src/main.rs index 3d33c394..375e8e1b 100644 --- a/examples/external-wakeup/src/main.rs +++ b/examples/external-wakeup/src/main.rs @@ -129,7 +129,8 @@ fn main() -> Result<(), baseview::Error> { .with_size(LogicalSize::new(512, 512)) .with_gl_config(GlConfig { alpha_bits: 8, ..GlConfig::default() }); - let window = Window::create(window_open_options, |ctx| FemtovgExample::new(ctx, receiver))?; + let window = + Window::create(window_open_options, None, |ctx| FemtovgExample::new(ctx, receiver))?; let waker = window.waker(); std::thread::spawn(|| run_thread(sender, waker)); diff --git a/examples/open_parented/src/main.rs b/examples/open_parented/src/main.rs index c4ecfd50..f9e5acd5 100644 --- a/examples/open_parented/src/main.rs +++ b/examples/open_parented/src/main.rs @@ -21,7 +21,7 @@ impl ParentWindowHandler { let window_open_options = WindowSettings::new().with_size(size).with_parent(&window).with_title("baseview child"); - let child_window = Window::create(window_open_options, ChildWindowHandler::new)?; + let child_window = Window::create(window_open_options, None, ChildWindowHandler::new)?; child_window.show()?; Ok(Self { surface: surface.into(), child_window }) @@ -116,7 +116,7 @@ fn main() -> Result<(), baseview::Error> { unsafe { baseview::assume_standalone_in_process() }; let window_open_options = WindowSettings::new().with_size(LogicalSize::new(512.0, 512.0)); - Window::create(window_open_options, ParentWindowHandler::new)?.run_until_closed()?; + Window::create(window_open_options, None, ParentWindowHandler::new)?.run_until_closed()?; Ok(()) } diff --git a/examples/open_window/src/main.rs b/examples/open_window/src/main.rs index 5074225e..0614ba60 100644 --- a/examples/open_window/src/main.rs +++ b/examples/open_window/src/main.rs @@ -140,7 +140,7 @@ fn main() -> Result<(), baseview::Error> { let (mut tx, rx) = RingBuffer::new(128); - let window = Window::create(window_open_options, |window| { + let window = Window::create(window_open_options, None, |window| { let ctx = softbuffer::Context::new(window.clone())?; let mut surface = softbuffer::Surface::new(&ctx, window.clone())?; let size = window.size().physical; diff --git a/examples/plugin_clack/src/gui.rs b/examples/plugin_clack/src/gui.rs index ccc0ed93..eddd2063 100644 --- a/examples/plugin_clack/src/gui.rs +++ b/examples/plugin_clack/src/gui.rs @@ -45,7 +45,7 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> { }); } - let window = Window::create_with_host(options, OpenWindowExample::new, host)?; + let window = Window::create(options, Some(host), OpenWindowExample::new)?; self.gui.replace(Some(ExamplePluginGui { handle: window })); Ok(()) diff --git a/examples/plugin_clack_femtovg/src/gui.rs b/examples/plugin_clack_femtovg/src/gui.rs index 8da7cbe2..c33a739a 100644 --- a/examples/plugin_clack_femtovg/src/gui.rs +++ b/examples/plugin_clack_femtovg/src/gui.rs @@ -45,7 +45,7 @@ impl PluginGuiImpl for ExamplePluginMainThread<'_> { }); } - let window = Window::create_with_host(options, FemtovgExample::new, host)?; + let window = Window::create(options, Some(host), FemtovgExample::new)?; self.gui.replace(Some(ExamplePluginGui { handle: window })); Ok(()) diff --git a/examples/render_femtovg/src/main.rs b/examples/render_femtovg/src/main.rs index d21c404a..4526ba27 100644 --- a/examples/render_femtovg/src/main.rs +++ b/examples/render_femtovg/src/main.rs @@ -118,7 +118,7 @@ fn main() -> Result<(), baseview::Error> { .with_size(LogicalSize::new(512, 512)) .with_gl_config(GlConfig { alpha_bits: 8, ..GlConfig::default() }); - Window::create(window_open_options, FemtovgExample::new)?.run_until_closed()?; + Window::create(window_open_options, None, FemtovgExample::new)?.run_until_closed()?; Ok(()) } diff --git a/examples/render_wgpu/src/main.rs b/examples/render_wgpu/src/main.rs index c423c3c1..8c66a806 100644 --- a/examples/render_wgpu/src/main.rs +++ b/examples/render_wgpu/src/main.rs @@ -219,7 +219,7 @@ fn main() -> Result<(), baseview::Error> { .with_size(LogicalSize::new(512, 512)) .with_max_size(LogicalSize::new(512, 512)); - Window::create(window_open_options, |c| pollster::block_on(WgpuExample::new(c)))? + Window::create(window_open_options, None, |c| pollster::block_on(WgpuExample::new(c)))? .run_until_closed()?; Ok(()) diff --git a/examples/test-frame-pacing/src/main.rs b/examples/test-frame-pacing/src/main.rs index 5ee7b627..204151e6 100644 --- a/examples/test-frame-pacing/src/main.rs +++ b/examples/test-frame-pacing/src/main.rs @@ -158,7 +158,7 @@ fn main() -> Result<(), baseview::Error> { .with_size(LogicalSize::new(512, 512)) .with_gl_config(GlConfig { alpha_bits: 8, ..GlConfig::default() }); - Window::create(window_open_options, FramePacingTest::new)?.run_until_closed()?; + Window::create(window_open_options, None, FramePacingTest::new)?.run_until_closed()?; Ok(()) } diff --git a/examples/timers/src/main.rs b/examples/timers/src/main.rs index 880569fc..b6d7771b 100644 --- a/examples/timers/src/main.rs +++ b/examples/timers/src/main.rs @@ -122,7 +122,7 @@ fn main() -> Result<(), baseview::Error> { .with_size(LogicalSize::new(512, 512)) .with_gl_config(GlConfig { alpha_bits: 8, ..GlConfig::default() }); - Window::create(window_open_options, FemtovgExample::new)?.run_until_closed() + Window::create(window_open_options, None, FemtovgExample::new)?.run_until_closed() } fn new_random_color() -> Color { diff --git a/src/window.rs b/src/window.rs index 0b62b5a8..ff3fda28 100644 --- a/src/window.rs +++ b/src/window.rs @@ -46,20 +46,6 @@ pub struct Window { } impl Window { - /// Creates a new window, using the given [`WindowSettings`] and a builder closure to - /// create the associated [`WindowHandler`]. - /// - /// This function creates the window but does not open or show it. - /// You must use the [`show`](Self::show) method to actually open it - /// (unless you use [`run_until_closed`](Self::run_until_closed), which does it automatically). - #[inline] - pub fn create( - options: WindowSettings, - handler: impl FnOnce(WindowContext) -> Result + Send + 'static, - ) -> Result { - Self::create_with_host(options, handler, None) - } - /// Creates a new window, using the given [`WindowSettings`] and a builder closure to /// create the associated [`WindowHandler`], as well as an optional [`Host`] containing callbacks /// to a potential system that is hosting the window (e.g. in a plug-in setting). @@ -67,18 +53,15 @@ impl Window { /// This function creates the window but does not open or show it. /// You must use the [`show`](Self::show) method to actually open it /// (unless you use [`run_until_closed`](Self::run_until_closed), which does it automatically). - /// - /// Calling this function with [`None`] for the `host` value is equivalent to calling - /// [`create`](Self::create). - pub fn create_with_host( - settings: WindowSettings, + #[inline] + pub fn create( + settings: WindowSettings, host: Option, handler: impl FnOnce(WindowContext) -> Result + Send + 'static, - host: impl Into>, ) -> Result { let initializer = WindowInitializer { settings, builder: WindowHandlerBuilder::new(handler), - host: host.into().unwrap_or_else(Host::default), + host: host.unwrap_or_default(), }; Ok(Self { diff --git a/tests/partial-rendering/src/main.rs b/tests/partial-rendering/src/main.rs index b849711d..2c8fb003 100644 --- a/tests/partial-rendering/src/main.rs +++ b/tests/partial-rendering/src/main.rs @@ -101,7 +101,7 @@ fn main() -> Result<(), baseview::Error> { .with_size(LogicalSize::new(512, 512)) .with_gl_config(GlConfig { alpha_bits: 8, ..GlConfig::default() }); - let window = Window::create(window_open_options, FemtovgExample::new)?; + let window = Window::create(window_open_options, None, FemtovgExample::new)?; window.run_until_closed()?; Ok(())