From 0f35f1eb58e265c00dd431a7d7acd2573395b87b Mon Sep 17 00:00:00 2001 From: Billy Messenger Date: Mon, 30 Mar 2026 15:49:15 -0500 Subject: [PATCH 1/3] add default methods to WindowOpenOptions --- src/gl/mod.rs | 2 +- src/window_open_options.rs | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/gl/mod.rs b/src/gl/mod.rs index 488cfd7f..b9dbc53b 100644 --- a/src/gl/mod.rs +++ b/src/gl/mod.rs @@ -21,7 +21,7 @@ mod macos; #[cfg(target_os = "macos")] use macos as platform; -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub struct GlConfig { pub version: (u8, u8), pub profile: Profile, diff --git a/src/window_open_options.rs b/src/window_open_options.rs index 7c5cd192..e5ff920d 100644 --- a/src/window_open_options.rs +++ b/src/window_open_options.rs @@ -1,15 +1,20 @@ use crate::Size; +#[cfg(feature = "opengl")] +use crate::gl::GlConfig; + /// The dpi scaling policy of the window -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Default, Debug, Clone, Copy, PartialEq)] pub enum WindowScalePolicy { /// Use the system's dpi scale factor + #[default] SystemScaleFactor, /// Use the given dpi scale factor (e.g. `1.0` = 96 dpi) ScaleFactor(f64), } /// The options for opening a new window +#[derive(Debug, Clone, PartialEq)] pub struct WindowOpenOptions { pub title: String, @@ -24,6 +29,32 @@ pub struct WindowOpenOptions { /// If provided, then an OpenGL context will be created for this window. You'll be able to /// access this context through [crate::Window::gl_context]. + /// + /// By default this is set to `Some(GlConfig::default())`. #[cfg(feature = "opengl")] - pub gl_config: Option, + pub gl_config: Option, +} + +impl WindowOpenOptions { + pub fn default_no_gl() -> Self { + Self { + title: String::from("baseview window"), + size: Size { width: 500.0, height: 400.0 }, + scale: WindowScalePolicy::default(), + #[cfg(feature = "opengl")] + gl_config: None, + } + } +} + +impl Default for WindowOpenOptions { + fn default() -> Self { + Self { + title: String::from("baseview window"), + size: Size { width: 500.0, height: 400.0 }, + scale: WindowScalePolicy::default(), + #[cfg(feature = "opengl")] + gl_config: Some(GlConfig::default()), + } + } } From 99e47580d63bb88afa44f9dfa14b6ad1379f24de Mon Sep 17 00:00:00 2001 From: Billy Messenger Date: Mon, 30 Mar 2026 15:56:22 -0500 Subject: [PATCH 2/3] rename default_no_gl to default_no_opengl --- src/window_open_options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/window_open_options.rs b/src/window_open_options.rs index e5ff920d..807a0028 100644 --- a/src/window_open_options.rs +++ b/src/window_open_options.rs @@ -36,7 +36,7 @@ pub struct WindowOpenOptions { } impl WindowOpenOptions { - pub fn default_no_gl() -> Self { + pub fn default_no_opengl() -> Self { Self { title: String::from("baseview window"), size: Size { width: 500.0, height: 400.0 }, From 92301d9fdcd77410f93f246b4de2a48777bb6b1c Mon Sep 17 00:00:00 2001 From: Billy Messenger Date: Tue, 28 Apr 2026 12:51:29 -0500 Subject: [PATCH 3/3] make WindowOpenOptions::gl_config default to None --- src/macos/window.rs | 2 +- src/window_open_options.rs | 18 +++--------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/macos/window.rs b/src/macos/window.rs index 57bca108..bf34a7c1 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -11,7 +11,7 @@ use cocoa::appkit::{ use cocoa::base::{id, nil, BOOL, NO, YES}; use cocoa::foundation::{NSAutoreleasePool, NSPoint, NSRect, NSSize, NSString}; use core_foundation::runloop::{ - CFRunLoop, CFRunLoopTimer, CFRunLoopTimerContext, __CFRunLoopTimer, kCFRunLoopDefaultMode, + __CFRunLoopTimer, kCFRunLoopDefaultMode, CFRunLoop, CFRunLoopTimer, CFRunLoopTimerContext, }; use keyboard_types::KeyboardEvent; use objc::class; diff --git a/src/window_open_options.rs b/src/window_open_options.rs index 807a0028..caadcc54 100644 --- a/src/window_open_options.rs +++ b/src/window_open_options.rs @@ -18,7 +18,7 @@ pub enum WindowScalePolicy { pub struct WindowOpenOptions { pub title: String, - /// The logical size of the window. + /// The logical size of the window /// /// These dimensions will be scaled by the scaling policy specified in `scale`. Mouse /// position will be passed back as logical coordinates. @@ -30,23 +30,11 @@ pub struct WindowOpenOptions { /// If provided, then an OpenGL context will be created for this window. You'll be able to /// access this context through [crate::Window::gl_context]. /// - /// By default this is set to `Some(GlConfig::default())`. + /// By default this is set to `None`. #[cfg(feature = "opengl")] pub gl_config: Option, } -impl WindowOpenOptions { - pub fn default_no_opengl() -> Self { - Self { - title: String::from("baseview window"), - size: Size { width: 500.0, height: 400.0 }, - scale: WindowScalePolicy::default(), - #[cfg(feature = "opengl")] - gl_config: None, - } - } -} - impl Default for WindowOpenOptions { fn default() -> Self { Self { @@ -54,7 +42,7 @@ impl Default for WindowOpenOptions { size: Size { width: 500.0, height: 400.0 }, scale: WindowScalePolicy::default(), #[cfg(feature = "opengl")] - gl_config: Some(GlConfig::default()), + gl_config: None, } } }