diff options
author | 2023-05-25 23:37:14 +0200 | |
---|---|---|
committer | 2023-05-25 23:37:14 +0200 | |
commit | c61a4cc21ca4d5019cd10df2f316ebbdb24061f1 (patch) | |
tree | aba611186298650931cd818d56e21feff35f974f /winit | |
parent | 6c6930b91df0d7637ed6c0f3f4e57a03c5e5896f (diff) | |
parent | 70fd296ccc69ae135bfbe693b8404d5409ae4332 (diff) | |
download | iced-c61a4cc21ca4d5019cd10df2f316ebbdb24061f1.tar.gz iced-c61a4cc21ca4d5019cd10df2f316ebbdb24061f1.tar.bz2 iced-c61a4cc21ca4d5019cd10df2f316ebbdb24061f1.zip |
Merge pull request #1738 from nicoburns/update-winit-0.28
Update to winit 0.28
Diffstat (limited to 'winit')
-rw-r--r-- | winit/Cargo.toml | 7 | ||||
-rw-r--r-- | winit/src/application.rs | 4 | ||||
-rw-r--r-- | winit/src/conversion.rs | 13 | ||||
-rw-r--r-- | winit/src/lib.rs | 5 | ||||
-rw-r--r-- | winit/src/settings.rs | 24 | ||||
-rw-r--r-- | winit/src/settings/windows.rs | 3 |
6 files changed, 37 insertions, 19 deletions
diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 58e13b3e..b75b1929 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -23,14 +23,15 @@ wayland-dlopen = ["winit/wayland-dlopen"] wayland-csd-adwaita = ["winit/wayland-csd-adwaita"] [dependencies] -window_clipboard = "0.2" +window_clipboard = "0.3" log = "0.4" thiserror = "1.0" +raw-window-handle = "0.5" [dependencies.winit] -version = "0.27" +version = "0.28" git = "https://github.com/iced-rs/winit.git" -rev = "940457522e9fb9f5dac228b0ecfafe0138b4048c" +rev = "ac1ddfe0bd870910b3aa64a18d386fdd55b30a1d" default-features = false [dependencies.iced_runtime] diff --git a/winit/src/application.rs b/winit/src/application.rs index 3d7c6e5d..4147be17 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -794,8 +794,8 @@ pub fn run_command<A, E>( window::Action::GainFocus => { window.focus_window(); } - window::Action::ChangeAlwaysOnTop(on_top) => { - window.set_always_on_top(on_top); + window::Action::ChangeLevel(level) => { + window.set_window_level(conversion::window_level(level)); } window::Action::FetchId(tag) => { proxy diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 16d9c1c2..dcae7074 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -140,6 +140,19 @@ pub fn window_event( } } +/// Converts a [`window::Level`] to a [`winit`] window level. +/// +/// [`winit`]: https://github.com/rust-windowing/winit +pub fn window_level(level: window::Level) -> winit::window::WindowLevel { + match level { + window::Level::Normal => winit::window::WindowLevel::Normal, + window::Level::AlwaysOnBottom => { + winit::window::WindowLevel::AlwaysOnBottom + } + window::Level::AlwaysOnTop => winit::window::WindowLevel::AlwaysOnTop, + } +} + /// Converts a [`Position`] to a [`winit`] logical position for a given monitor. /// /// [`winit`]: https://github.com/rust-windowing/winit diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 62d66d5e..4776ea2c 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -25,9 +25,10 @@ clippy::from_over_into, clippy::needless_borrow, clippy::new_without_default, - clippy::useless_conversion + clippy::useless_conversion, + unsafe_code )] -#![forbid(rust_2018_idioms, unsafe_code)] +#![forbid(rust_2018_idioms)] #![allow(clippy::inherent_to_string, clippy::type_complexity)] #![cfg_attr(docsrs, feature(doc_auto_cfg))] pub use iced_graphics as graphics; diff --git a/winit/src/settings.rs b/winit/src/settings.rs index be0ab329..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::core::window::Icon; +use crate::core::window::{Icon, Level}; use crate::Position; use winit::monitor::MonitorHandle; @@ -81,8 +81,8 @@ 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<Icon>, @@ -102,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() @@ -128,7 +128,7 @@ impl Window { .with_decorations(self.decorations) .with_transparent(self.transparent) .with_window_icon(self.icon.and_then(conversion::icon)) - .with_always_on_top(self.always_on_top) + .with_window_level(conversion::window_level(self.level)) .with_visible(self.visible); if let Some(position) = conversion::position( @@ -157,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); @@ -167,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); } @@ -205,7 +207,7 @@ impl Default for Window { resizable: true, decorations: true, transparent: false, - always_on_top: false, + level: Level::default(), icon: None, platform_specific: Default::default(), } diff --git a/winit/src/settings/windows.rs b/winit/src/settings/windows.rs index ff03a9c5..45d753bd 100644 --- a/winit/src/settings/windows.rs +++ b/winit/src/settings/windows.rs @@ -1,10 +1,11 @@ //! Platform specific settings for Windows. +use raw_window_handle::RawWindowHandle; /// The platform specific window settings of an application. #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct PlatformSpecific { /// Parent window - pub parent: Option<winit::platform::windows::HWND>, + pub parent: Option<RawWindowHandle>, /// Drag and drop support pub drag_and_drop: bool, |