summaryrefslogtreecommitdiffstats
path: root/winit/src/settings.rs
diff options
context:
space:
mode:
authorLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
committerLibravatar Bingus <shankern@protonmail.com>2023-07-12 12:23:18 -0700
commit633f405f3f78bc7f82d2b2061491b0e011137451 (patch)
tree5ebfc1f45d216a5c14a90492563599e6969eab4d /winit/src/settings.rs
parent41836dd80d0534608e7aedfbf2319c540a23de1a (diff)
parent21bd51426d900e271206f314e0c915dd41065521 (diff)
downloadiced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.gz
iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.bz2
iced-633f405f3f78bc7f82d2b2061491b0e011137451.zip
Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts: # Cargo.toml # core/src/window/icon.rs # core/src/window/id.rs # core/src/window/position.rs # core/src/window/settings.rs # examples/integration/src/main.rs # examples/integration_opengl/src/main.rs # glutin/src/application.rs # native/src/subscription.rs # native/src/window.rs # runtime/src/window/action.rs # src/lib.rs # src/window.rs # winit/Cargo.toml # winit/src/application.rs # winit/src/icon.rs # winit/src/settings.rs # winit/src/window.rs
Diffstat (limited to 'winit/src/settings.rs')
-rw-r--r--winit/src/settings.rs61
1 files changed, 16 insertions, 45 deletions
diff --git a/winit/src/settings.rs b/winit/src/settings.rs
index 88d7c1de..40b3d487 100644
--- a/winit/src/settings.rs
+++ b/winit/src/settings.rs
@@ -22,7 +22,7 @@ mod platform;
pub use platform::PlatformSpecific;
use crate::conversion;
-use crate::Icon;
+use crate::core::window::{Icon, Level};
use crate::Position;
use winit::monitor::MonitorHandle;
@@ -50,20 +50,8 @@ pub struct Settings<Flags> {
/// Whether the [`Application`] should exit when the user requests the
/// window to close (e.g. the user presses the close button).
///
- /// NOTE: This is not used for `multi-window`, instead check [`Application::close_requested`].
- ///
- /// [`close_requested`]: crate::multi_window::Application::close_requested
- ///
/// [`Application`]: crate::Application
pub exit_on_close_request: bool,
-
- /// Whether the [`Application`] should try to build the context
- /// using OpenGL ES first then OpenGL.
- ///
- /// NOTE: Only works for the `glow` backend.
- ///
- /// [`Application`]: crate::Application
- pub try_opengles_first: bool,
}
/// The window settings of an application.
@@ -93,11 +81,11 @@ pub struct Window {
/// Whether the window should be transparent.
pub transparent: bool,
- /// Whether the window will always be on top of other windows.
- pub always_on_top: bool,
+ /// The window [`Level`].
+ pub level: Level,
/// The window icon, which is also usually used in the taskbar
- pub icon: Option<winit::window::Icon>,
+ pub icon: Option<Icon>,
/// Platform specific settings.
pub platform_specific: platform::PlatformSpecific,
@@ -114,7 +102,7 @@ impl fmt::Debug for Window {
.field("resizable", &self.resizable)
.field("decorations", &self.decorations)
.field("transparent", &self.transparent)
- .field("always_on_top", &self.always_on_top)
+ .field("level", &self.level)
.field("icon", &self.icon.is_some())
.field("platform_specific", &self.platform_specific)
.finish()
@@ -139,8 +127,9 @@ impl Window {
.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_window_icon(self.icon.and_then(conversion::icon))
+ .with_window_level(conversion::window_level(self.level))
+ .with_visible(self.visible);
if let Some(position) = conversion::position(
primary_monitor.as_ref(),
@@ -168,7 +157,9 @@ impl Window {
target_os = "openbsd"
))]
{
- use ::winit::platform::unix::WindowBuilderExtUnix;
+ // `with_name` is available on both `WindowBuilderExtWayland` and `WindowBuilderExtX11` and they do
+ // exactly the same thing. We arbitrarily choose `WindowBuilderExtWayland` here.
+ use ::winit::platform::wayland::WindowBuilderExtWayland;
if let Some(id) = _id {
window_builder = window_builder.with_name(id.clone(), id);
@@ -178,11 +169,11 @@ impl Window {
#[cfg(target_os = "windows")]
{
use winit::platform::windows::WindowBuilderExtWindows;
-
- if let Some(parent) = self.platform_specific.parent {
- window_builder = window_builder.with_parent_window(parent);
+ #[allow(unsafe_code)]
+ unsafe {
+ window_builder = window_builder
+ .with_parent_window(self.platform_specific.parent);
}
-
window_builder = window_builder
.with_drag_and_drop(self.platform_specific.drag_and_drop);
}
@@ -216,29 +207,9 @@ impl Default for Window {
resizable: true,
decorations: true,
transparent: false,
- always_on_top: false,
+ level: Level::default(),
icon: None,
platform_specific: Default::default(),
}
}
}
-
-impl From<iced_native::window::Settings> for Window {
- fn from(settings: iced_native::window::Settings) -> Self {
- Self {
- size: settings.size,
- position: settings.position,
- min_size: settings.min_size,
- max_size: settings.max_size,
- visible: settings.visible,
- resizable: settings.resizable,
- decorations: settings.decorations,
- transparent: settings.transparent,
- always_on_top: settings.always_on_top,
- icon: settings.icon.and_then(|icon| {
- Icon::try_from(icon).map(winit::window::Icon::from).ok()
- }),
- platform_specific: Default::default(),
- }
- }
-}