From 5c45d36d1a8cfd92cd1a454a7f4deedcd4d13fe7 Mon Sep 17 00:00:00 2001 From: TimUntersberger Date: Fri, 25 Jun 2021 17:16:44 +0200 Subject: wip --- winit/src/settings.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 941d88ce..0508cd9b 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -35,6 +35,9 @@ pub struct Window { /// The size of the window. pub size: (u32, u32), + /// The position of the window. + pub position: (u32, u32), + /// The minimum size of the window. pub min_size: Option<(u32, u32)>, @@ -75,6 +78,7 @@ impl Window { window_builder = window_builder .with_title(title) .with_inner_size(winit::dpi::LogicalSize { width, height }) + .with_outer_position(self.position) .with_resizable(self.resizable) .with_decorations(self.decorations) .with_transparent(self.transparent) -- cgit From de79a01b88e1610d374ed06077ac78f3e10b9c3d Mon Sep 17 00:00:00 2001 From: TimUntersberger Date: Fri, 25 Jun 2021 18:03:18 +0200 Subject: done --- winit/src/settings.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 0508cd9b..1769c676 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -36,7 +36,7 @@ pub struct Window { pub size: (u32, u32), /// The position of the window. - pub position: (u32, u32), + pub position: (i32, i32), /// The minimum size of the window. pub min_size: Option<(u32, u32)>, @@ -78,7 +78,7 @@ impl Window { window_builder = window_builder .with_title(title) .with_inner_size(winit::dpi::LogicalSize { width, height }) - .with_outer_position(self.position) + .with_position(winit::dpi::LogicalPosition { x: self.position.0, y: self.position.1 }) .with_resizable(self.resizable) .with_decorations(self.decorations) .with_transparent(self.transparent) @@ -116,6 +116,7 @@ impl Default for Window { fn default() -> Window { Window { size: (1024, 768), + position: (100, 100), min_size: None, max_size: None, resizable: true, -- cgit From 72b3bf95de3f11812b1541fe2ffea76a515aee79 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 21 Jul 2021 18:59:24 +0700 Subject: Improve `window::Position` API --- winit/src/settings.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'winit/src/settings.rs') diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 1769c676..743f79bc 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -9,7 +9,7 @@ mod platform; pub use platform::PlatformSpecific; use crate::conversion; -use crate::Mode; +use crate::{Mode, Position}; use winit::monitor::MonitorHandle; use winit::window::WindowBuilder; @@ -36,7 +36,7 @@ pub struct Window { pub size: (u32, u32), /// The position of the window. - pub position: (i32, i32), + pub position: Position, /// The minimum size of the window. pub min_size: Option<(u32, u32)>, @@ -78,15 +78,21 @@ impl Window { window_builder = window_builder .with_title(title) .with_inner_size(winit::dpi::LogicalSize { width, height }) - .with_position(winit::dpi::LogicalPosition { x: self.position.0, y: self.position.1 }) .with_resizable(self.resizable) .with_decorations(self.decorations) .with_transparent(self.transparent) .with_window_icon(self.icon) .with_always_on_top(self.always_on_top) - .with_fullscreen(conversion::fullscreen(primary_monitor, mode)) .with_visible(conversion::visible(mode)); + if let Some(position) = conversion::position( + primary_monitor.as_ref(), + self.size, + self.position, + ) { + window_builder = window_builder.with_position(position); + } + if let Some((width, height)) = self.min_size { window_builder = window_builder .with_min_inner_size(winit::dpi::LogicalSize { width, height }); @@ -108,6 +114,9 @@ impl Window { .with_drag_and_drop(self.platform_specific.drag_and_drop); } + window_builder = window_builder + .with_fullscreen(conversion::fullscreen(primary_monitor, mode)); + window_builder } } @@ -116,7 +125,7 @@ impl Default for Window { fn default() -> Window { Window { size: (1024, 768), - position: (100, 100), + position: Position::default(), min_size: None, max_size: None, resizable: true, -- cgit