From 0231ed6f1d5929d84bb81e6673d3319a24f08b16 Mon Sep 17 00:00:00 2001 From: traxys Date: Mon, 20 Mar 2023 00:18:41 +0100 Subject: winit: Fix replacement of node in wasm Replacing a node ends up with the following error: Node.replaceChild: Child to be replaced is not a child of this node It seems that Node.replaceChild is not recommended, and instead Element.replaceWith should be preferred. Using it avoids the panic. --- winit/src/application.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index b13b7214..31654f26 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -179,13 +179,17 @@ where .unwrap_or(None) }); - let _ = match target { - Some(node) => node - .replace_child(&canvas, &node) - .expect(&format!("Could not replace #{}", node.id())), - None => body - .append_child(&canvas) - .expect("Append canvas to HTML body"), + match target { + Some(node) => { + let _ = node + .replace_with_with_node_1(&canvas) + .expect(&format!("Could not replace #{}", node.id())); + } + None => { + let _ = body + .append_child(&canvas) + .expect("Append canvas to HTML body"); + } }; } -- cgit From cb78dc548b04b951d9ee86d18a5fbef8c591dd4e Mon Sep 17 00:00:00 2001 From: Jacob Kiesel Date: Fri, 31 Mar 2023 20:37:09 -0600 Subject: re-expose winit features for window servers in Linux --- winit/Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'winit') diff --git a/winit/Cargo.toml b/winit/Cargo.toml index dd5c12c2..255b28bb 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -11,11 +11,16 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"] categories = ["gui"] [features] +default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"] trace = ["tracing", "tracing-core", "tracing-subscriber"] chrome-trace = ["trace", "tracing-chrome"] debug = ["iced_native/debug"] system = ["sysinfo"] application = [] +x11 = ["winit/x11"] +wayland = ["winit/wayland"] +wayland-dlopen = ["winit/wayland-dlopen"] +wayland-csd-adwaita = ["winit/wayland-csd-adwaita"] [dependencies] window_clipboard = "0.2" @@ -26,6 +31,7 @@ thiserror = "1.0" version = "0.27" git = "https://github.com/iced-rs/winit.git" rev = "940457522e9fb9f5dac228b0ecfafe0138b4048c" +default-features = false [dependencies.iced_native] version = "0.9" -- cgit From 7e7e66586d990788ffd77b17e98357e74252f497 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 12 Apr 2023 04:37:39 +0200 Subject: Show `NotAllowed` as mouse icon when hovering a disabled `TextInput` --- winit/src/conversion.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'winit') diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 1b2ead36..d2dc9c06 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -236,6 +236,7 @@ pub fn mouse_interaction( winit::window::CursorIcon::EwResize } Interaction::ResizingVertically => winit::window::CursorIcon::NsResize, + Interaction::NotAllowed => winit::window::CursorIcon::NotAllowed, } } -- cgit From 5a056ce0510343621305474af74ade1db028c01a Mon Sep 17 00:00:00 2001 From: Night_Hunter Date: Wed, 12 Apr 2023 18:47:53 +1200 Subject: add action set icon while running (#1590) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * set windows icon live action * change get icon to insto raw * remove mobile docs * format * fix format * add file methods to Icon * Rename action to `ChangeIcon` and tidy up `Icon` modules * Fix documentation of `icon::Error` * Remove unnecessary `\` in `icon` documentation * Remove `etc.` from `Icon` documentation --------- Co-authored-by: Héctor Ramón Jiménez --- winit/src/application.rs | 3 +++ winit/src/conversion.rs | 9 +++++++++ winit/src/settings.rs | 7 ++++--- winit/src/window.rs | 9 ++++++++- 4 files changed, 24 insertions(+), 4 deletions(-) (limited to 'winit') diff --git a/winit/src/application.rs b/winit/src/application.rs index 31654f26..dd345785 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -770,6 +770,9 @@ pub fn run_command( mode, )); } + window::Action::ChangeIcon(icon) => { + window.set_window_icon(conversion::icon(icon)) + } window::Action::FetchMode(tag) => { let mode = if window.is_visible().unwrap_or(true) { conversion::mode(window.fullscreen()) diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index d2dc9c06..cf066ef6 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -510,6 +510,15 @@ pub fn user_attention( } } +/// Converts some [`Icon`] into it's `winit` counterpart. +/// +/// Returns `None` if there is an error during the conversion. +pub fn icon(icon: window::Icon) -> Option { + let (pixels, size) = icon.into_raw(); + + winit::window::Icon::from_rgba(pixels, size.width, size.height).ok() +} + // As defined in: http://www.unicode.org/faq/private_use.html pub(crate) fn is_private_use_character(c: char) -> bool { matches!( diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 78d58000..6658773d 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -92,7 +92,7 @@ pub struct Window { pub always_on_top: bool, /// The window icon, which is also usually used in the taskbar - pub icon: Option, + pub icon: Option, /// Platform specific settings. pub platform_specific: platform::PlatformSpecific, @@ -134,8 +134,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_always_on_top(self.always_on_top) + .with_visible(self.visible); if let Some(position) = conversion::position( primary_monitor.as_ref(), diff --git a/winit/src/window.rs b/winit/src/window.rs index 961562bd..ba0180c8 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -2,7 +2,9 @@ use crate::command::{self, Command}; use iced_native::window; -pub use window::{frames, Event, Mode, RedrawRequest, UserAttention}; +pub use window::{ + frames, icon, Event, Icon, Mode, RedrawRequest, UserAttention, +}; /// Closes the current window and exits the application. pub fn close() -> Command { @@ -104,3 +106,8 @@ pub fn fetch_id( f, )))) } + +/// Changes the [`Icon`] of the window. +pub fn change_icon(icon: Icon) -> Command { + Command::single(command::Action::Window(window::Action::ChangeIcon(icon))) +} -- cgit From c79cc2d2b3df99f69b048c68e503916c779a1102 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 13 Apr 2023 08:31:17 +0200 Subject: Bump versions :tada: --- winit/Cargo.toml | 6 +++--- winit/README.md | 2 +- winit/src/conversion.rs | 12 ++++++------ winit/src/lib.rs | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'winit') diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 255b28bb..8788b667 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iced_winit" -version = "0.8.0" +version = "0.9.1" authors = ["Héctor Ramón Jiménez "] edition = "2021" description = "A winit runtime for Iced" @@ -34,11 +34,11 @@ rev = "940457522e9fb9f5dac228b0ecfafe0138b4048c" default-features = false [dependencies.iced_native] -version = "0.9" +version = "0.10" path = "../native" [dependencies.iced_graphics] -version = "0.7" +version = "0.8" path = "../graphics" [dependencies.iced_futures] diff --git a/winit/README.md b/winit/README.md index 83810473..91307970 100644 --- a/winit/README.md +++ b/winit/README.md @@ -20,7 +20,7 @@ It exposes a renderer-agnostic `Application` trait that can be implemented and t Add `iced_winit` as a dependency in your `Cargo.toml`: ```toml -iced_winit = "0.8" +iced_winit = "0.9" ``` __Iced moves fast and the `master` branch can contain breaking changes!__ If diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index cf066ef6..e416c073 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -1,7 +1,7 @@ //! Convert [`winit`] types into [`iced_native`] types, and viceversa. //! //! [`winit`]: https://github.com/rust-windowing/winit -//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native +//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native use crate::keyboard; use crate::mouse; use crate::touch; @@ -218,7 +218,7 @@ pub fn mode(mode: Option) -> window::Mode { /// Converts a `MouseCursor` from [`iced_native`] to a [`winit`] cursor icon. /// /// [`winit`]: https://github.com/rust-windowing/winit -/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native pub fn mouse_interaction( interaction: mouse::Interaction, ) -> winit::window::CursorIcon { @@ -243,7 +243,7 @@ pub fn mouse_interaction( /// Converts a `MouseButton` from [`winit`] to an [`iced_native`] mouse button. /// /// [`winit`]: https://github.com/rust-windowing/winit -/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native pub fn mouse_button(mouse_button: winit::event::MouseButton) -> mouse::Button { match mouse_button { winit::event::MouseButton::Left => mouse::Button::Left, @@ -259,7 +259,7 @@ pub fn mouse_button(mouse_button: winit::event::MouseButton) -> mouse::Button { /// modifiers state. /// /// [`winit`]: https://github.com/rust-windowing/winit -/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native pub fn modifiers( modifiers: winit::event::ModifiersState, ) -> keyboard::Modifiers { @@ -286,7 +286,7 @@ pub fn cursor_position( /// Converts a `Touch` from [`winit`] to an [`iced_native`] touch event. /// /// [`winit`]: https://github.com/rust-windowing/winit -/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native pub fn touch_event( touch: winit::event::Touch, scale_factor: f64, @@ -317,7 +317,7 @@ pub fn touch_event( /// Converts a `VirtualKeyCode` from [`winit`] to an [`iced_native`] key code. /// /// [`winit`]: https://github.com/rust-windowing/winit -/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native pub fn key_code( virtual_keycode: winit::event::VirtualKeyCode, ) -> keyboard::KeyCode { diff --git a/winit/src/lib.rs b/winit/src/lib.rs index 3a33e174..6b6c6045 100644 --- a/winit/src/lib.rs +++ b/winit/src/lib.rs @@ -11,7 +11,7 @@ //! Additionally, a [`conversion`] module is available for users that decide to //! implement a custom event loop. //! -//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native +//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.9/native //! [`winit`]: https://github.com/rust-windowing/winit //! [`conversion`]: crate::conversion #![doc( -- cgit