mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Allow introspection of WindowBuilder attributes
Makes WindowAttributes public and adds window_attributes() getter to WindowBuilder. In version 0.27, the WindowAttributes struct was made private, but this removed the ability to introspect the default WindowBuilder values.
This commit is contained in:
parent
b457329003
commit
422c6b1987
|
@ -63,6 +63,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On macOS, fix the mouse buttons other than left/right/middle being reported as middle.
|
- On macOS, fix the mouse buttons other than left/right/middle being reported as middle.
|
||||||
- On Wayland, support fractional scaling via the wp-fractional-scale protocol.
|
- On Wayland, support fractional scaling via the wp-fractional-scale protocol.
|
||||||
- On web, fix removal of mouse event listeners from the global object upon window distruction.
|
- On web, fix removal of mouse event listeners from the global object upon window distruction.
|
||||||
|
- Add WindowAttributes getter to WindowBuilder to allow introspection of default values.
|
||||||
|
|
||||||
# 0.27.5
|
# 0.27.5
|
||||||
|
|
||||||
|
|
|
@ -455,7 +455,7 @@ impl WinitUIWindow {
|
||||||
|
|
||||||
this.setRootViewController(Some(view_controller));
|
this.setRootViewController(Some(view_controller));
|
||||||
|
|
||||||
match window_attributes.fullscreen {
|
match window_attributes.fullscreen.clone().map(Into::into) {
|
||||||
Some(Fullscreen::Exclusive(ref video_mode)) => {
|
Some(Fullscreen::Exclusive(ref video_mode)) => {
|
||||||
let monitor = video_mode.monitor();
|
let monitor = video_mode.monitor();
|
||||||
let screen = monitor.ui_screen();
|
let screen = monitor.ui_screen();
|
||||||
|
|
|
@ -416,7 +416,8 @@ impl Window {
|
||||||
// TODO: transparency, visible
|
// TODO: transparency, visible
|
||||||
|
|
||||||
let main_screen = UIScreen::main(mtm);
|
let main_screen = UIScreen::main(mtm);
|
||||||
let screen = match window_attributes.fullscreen {
|
let fullscreen = window_attributes.fullscreen.clone().map(Into::into);
|
||||||
|
let screen = match fullscreen {
|
||||||
Some(Fullscreen::Exclusive(ref video_mode)) => video_mode.monitor.ui_screen(),
|
Some(Fullscreen::Exclusive(ref video_mode)) => video_mode.monitor.ui_screen(),
|
||||||
Some(Fullscreen::Borderless(Some(ref monitor))) => monitor.ui_screen(),
|
Some(Fullscreen::Borderless(Some(ref monitor))) => monitor.ui_screen(),
|
||||||
Some(Fullscreen::Borderless(None)) | None => &main_screen,
|
Some(Fullscreen::Borderless(None)) | None => &main_screen,
|
||||||
|
|
|
@ -240,7 +240,7 @@ impl Window {
|
||||||
window.set_title(attributes.title);
|
window.set_title(attributes.title);
|
||||||
|
|
||||||
// Set fullscreen/maximized if so was requested.
|
// Set fullscreen/maximized if so was requested.
|
||||||
match attributes.fullscreen {
|
match attributes.fullscreen.map(Into::into) {
|
||||||
Some(Fullscreen::Exclusive(_)) => {
|
Some(Fullscreen::Exclusive(_)) => {
|
||||||
warn!("`Fullscreen::Exclusive` is ignored on Wayland")
|
warn!("`Fullscreen::Exclusive` is ignored on Wayland")
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,7 +484,8 @@ impl UnownedWindow {
|
||||||
window.set_maximized_inner(window_attrs.maximized).queue();
|
window.set_maximized_inner(window_attrs.maximized).queue();
|
||||||
}
|
}
|
||||||
if window_attrs.fullscreen.is_some() {
|
if window_attrs.fullscreen.is_some() {
|
||||||
if let Some(flusher) = window.set_fullscreen_inner(window_attrs.fullscreen.clone())
|
if let Some(flusher) =
|
||||||
|
window.set_fullscreen_inner(window_attrs.fullscreen.clone().map(Into::into))
|
||||||
{
|
{
|
||||||
flusher.queue()
|
flusher.queue()
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,7 @@ impl WinitWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
let this = autoreleasepool(|_| {
|
let this = autoreleasepool(|_| {
|
||||||
let screen = match &attrs.fullscreen {
|
let screen = match attrs.fullscreen.clone().map(Into::into) {
|
||||||
Some(Fullscreen::Borderless(Some(monitor)))
|
Some(Fullscreen::Borderless(Some(monitor)))
|
||||||
| Some(Fullscreen::Exclusive(VideoMode { monitor, .. })) => {
|
| Some(Fullscreen::Exclusive(VideoMode { monitor, .. })) => {
|
||||||
monitor.ns_screen().or_else(NSScreen::main)
|
monitor.ns_screen().or_else(NSScreen::main)
|
||||||
|
@ -459,7 +459,7 @@ impl WinitWindow {
|
||||||
let delegate = WinitWindowDelegate::new(&this, attrs.fullscreen.is_some());
|
let delegate = WinitWindowDelegate::new(&this, attrs.fullscreen.is_some());
|
||||||
|
|
||||||
// Set fullscreen mode after we setup everything
|
// Set fullscreen mode after we setup everything
|
||||||
this.set_fullscreen(attrs.fullscreen);
|
this.set_fullscreen(attrs.fullscreen.map(Into::into));
|
||||||
|
|
||||||
// Setting the window as key has to happen *after* we set the fullscreen
|
// Setting the window as key has to happen *after* we set the fullscreen
|
||||||
// state, since otherwise we'll briefly see the window at normal size
|
// state, since otherwise we'll briefly see the window at normal size
|
||||||
|
|
|
@ -1011,7 +1011,7 @@ impl<'a, T: 'static> InitData<'a, T> {
|
||||||
win.set_enabled_buttons(attributes.enabled_buttons);
|
win.set_enabled_buttons(attributes.enabled_buttons);
|
||||||
|
|
||||||
if attributes.fullscreen.is_some() {
|
if attributes.fullscreen.is_some() {
|
||||||
win.set_fullscreen(attributes.fullscreen);
|
win.set_fullscreen(attributes.fullscreen.map(Into::into));
|
||||||
force_window_active(win.window.0);
|
force_window_active(win.window.0);
|
||||||
} else {
|
} else {
|
||||||
let size = attributes
|
let size = attributes
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl fmt::Debug for WindowBuilder {
|
||||||
|
|
||||||
/// Attributes to use when creating a window.
|
/// Attributes to use when creating a window.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct WindowAttributes {
|
pub struct WindowAttributes {
|
||||||
pub inner_size: Option<Size>,
|
pub inner_size: Option<Size>,
|
||||||
pub min_inner_size: Option<Size>,
|
pub min_inner_size: Option<Size>,
|
||||||
pub max_inner_size: Option<Size>,
|
pub max_inner_size: Option<Size>,
|
||||||
|
@ -128,7 +128,7 @@ pub(crate) struct WindowAttributes {
|
||||||
pub resizable: bool,
|
pub resizable: bool,
|
||||||
pub enabled_buttons: WindowButtons,
|
pub enabled_buttons: WindowButtons,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub fullscreen: Option<platform_impl::Fullscreen>,
|
pub fullscreen: Option<Fullscreen>,
|
||||||
pub maximized: bool,
|
pub maximized: bool,
|
||||||
pub visible: bool,
|
pub visible: bool,
|
||||||
pub transparent: bool,
|
pub transparent: bool,
|
||||||
|
@ -176,6 +176,11 @@ impl WindowBuilder {
|
||||||
Default::default()
|
Default::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the current window attributes.
|
||||||
|
pub fn window_attributes(&self) -> &WindowAttributes {
|
||||||
|
&self.window
|
||||||
|
}
|
||||||
|
|
||||||
/// Requests the window to be of specific dimensions.
|
/// Requests the window to be of specific dimensions.
|
||||||
///
|
///
|
||||||
/// If this is not set, some platform-specific dimensions will be used.
|
/// If this is not set, some platform-specific dimensions will be used.
|
||||||
|
@ -279,7 +284,7 @@ impl WindowBuilder {
|
||||||
/// See [`Window::set_fullscreen`] for details.
|
/// See [`Window::set_fullscreen`] for details.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn with_fullscreen(mut self, fullscreen: Option<Fullscreen>) -> Self {
|
pub fn with_fullscreen(mut self, fullscreen: Option<Fullscreen>) -> Self {
|
||||||
self.window.fullscreen = fullscreen.map(|f| f.into());
|
self.window.fullscreen = fullscreen;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue