From 9506fb1181e60e78d92b6f0712d385371966e07f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 11 Feb 2023 03:06:42 +0100 Subject: Hide window until `Renderer` has been initialized --- winit/src/application.rs | 20 +++++++++++++++----- winit/src/settings.rs | 3 +-- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index c1836ed9..769fe9dd 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -147,11 +147,15 @@ where #[cfg(target_arch = "wasm32")] let target = settings.window.platform_specific.target.clone(); - let builder = settings.window.into_builder( - &application.title(), - event_loop.primary_monitor(), - settings.id, - ); + let should_be_visible = settings.window.visible; + let builder = settings + .window + .into_builder( + &application.title(), + event_loop.primary_monitor(), + settings.id, + ) + .with_visible(false); log::info!("Window builder: {:#?}", builder); @@ -202,6 +206,7 @@ where control_sender, init_command, window, + should_be_visible, settings.exit_on_close_request, ); @@ -268,6 +273,7 @@ async fn run_instance( mut control_sender: mpsc::UnboundedSender, init_command: Command, window: winit::window::Window, + should_be_visible: bool, exit_on_close_request: bool, ) where A: Application + 'static, @@ -295,6 +301,10 @@ async fn run_instance( physical_size.height, ); + if should_be_visible { + window.set_visible(true); + } + run_command( &application, &mut cache, diff --git a/winit/src/settings.rs b/winit/src/settings.rs index 9bbdef5c..45f38833 100644 --- a/winit/src/settings.rs +++ b/winit/src/settings.rs @@ -114,8 +114,7 @@ impl Window { .with_decorations(self.decorations) .with_transparent(self.transparent) .with_window_icon(self.icon) - .with_always_on_top(self.always_on_top) - .with_visible(self.visible); + .with_always_on_top(self.always_on_top); if let Some(position) = conversion::position( primary_monitor.as_ref(), -- cgit From d1d13f6f160af73e549e2c2dd8a9d7991f10f1f6 Mon Sep 17 00:00:00 2001 From: Night_Hunter Date: Sat, 10 Dec 2022 01:42:51 +1300 Subject: add always on top action --- winit/src/application.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index 769fe9dd..fda559d0 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -788,6 +788,9 @@ pub fn run_command( user_attention.map(conversion::user_attention), ), window::Action::GainFocus => window.focus_window(), + window::Action::AlwaysOnTop(value) => { + window.set_always_on_top(value) + } }, command::Action::System(action) => match action { system::Action::QueryInformation(_tag) => { -- cgit From 095ecf016b53ad25337663fb9f11a84f373150e0 Mon Sep 17 00:00:00 2001 From: Night_Hunter Date: Thu, 29 Dec 2022 13:30:14 +1300 Subject: update docs and change to SetAlwaysOnTop --- winit/src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index fda559d0..d2e40de0 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -788,7 +788,7 @@ pub fn run_command( user_attention.map(conversion::user_attention), ), window::Action::GainFocus => window.focus_window(), - window::Action::AlwaysOnTop(value) => { + window::Action::SetAlwaysOnTop(value) => { window.set_always_on_top(value) } }, -- cgit From df861d9ece5e8695d05d08f104d37f55222fb363 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 17 Feb 2023 13:22:45 +0100 Subject: Rename `SetAlwaysOnTop` to `ChangeAlwaysOnTop` --- winit/src/application.rs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index d2e40de0..1f37ffef 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -747,11 +747,11 @@ pub fn run_command( height, }); } - window::Action::Maximize(value) => { - window.set_maximized(value); + window::Action::Maximize(maximized) => { + window.set_maximized(maximized); } - window::Action::Minimize(value) => { - window.set_minimized(value); + window::Action::Minimize(minimized) => { + window.set_minimized(minimized); } window::Action::Move { x, y } => { window.set_outer_position(winit::dpi::LogicalPosition { @@ -781,15 +781,18 @@ pub fn run_command( window.set_maximized(!window.is_maximized()) } window::Action::ToggleDecorations => { - window.set_decorations(!window.is_decorated()) + window.set_decorations(!window.is_decorated()); } - window::Action::RequestUserAttention(user_attention) => window - .request_user_attention( + window::Action::RequestUserAttention(user_attention) => { + window.request_user_attention( user_attention.map(conversion::user_attention), - ), - window::Action::GainFocus => window.focus_window(), - window::Action::SetAlwaysOnTop(value) => { - window.set_always_on_top(value) + ); + } + window::Action::GainFocus => { + window.focus_window(); + } + window::Action::ChangeAlwaysOnTop(on_top) => { + window.set_always_on_top(on_top); } }, command::Action::System(action) => match action { -- cgit From db65c6904d38fe37ad0c31a11242d55f5f773c94 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 17 Feb 2023 13:24:46 +0100 Subject: Expose `change_always_on_top` helper in `window` module --- winit/src/window.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'winit/src') diff --git a/winit/src/window.rs b/winit/src/window.rs index 6e3a383a..3d5a765b 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -23,13 +23,17 @@ pub fn resize(width: u32, height: u32) -> Command { } /// Maximizes the window. -pub fn maximize(value: bool) -> Command { - Command::single(command::Action::Window(window::Action::Maximize(value))) +pub fn maximize(maximized: bool) -> Command { + Command::single(command::Action::Window(window::Action::Maximize( + maximized, + ))) } /// Minimes the window. -pub fn minimize(value: bool) -> Command { - Command::single(command::Action::Window(window::Action::Minimize(value))) +pub fn minimize(minimized: bool) -> Command { + Command::single(command::Action::Window(window::Action::Minimize( + minimized, + ))) } /// Moves a window to the given logical coordinates. @@ -84,3 +88,10 @@ pub fn request_user_attention( pub fn gain_focus() -> Command { Command::single(command::Action::Window(window::Action::GainFocus)) } + +/// Changes whether or not the window will always be on top of other windows. +pub fn change_always_on_top(on_top: bool) -> Command { + Command::single(command::Action::Window(window::Action::ChangeAlwaysOnTop( + on_top, + ))) +} -- cgit From 9f75f01ddb7a13a3ab1cffdfa59997cb5b131f72 Mon Sep 17 00:00:00 2001 From: Night_Hunter Date: Sat, 10 Dec 2022 01:54:57 +1300 Subject: add action to get window id --- winit/src/application.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index 1f37ffef..3fdec658 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -794,6 +794,11 @@ pub fn run_command( window::Action::ChangeAlwaysOnTop(on_top) => { window.set_always_on_top(on_top); } + window::Action::FetchId(tag) => { + proxy + .send_event(tag(window.id().into())) + .expect("Send message to event loop"); + } }, command::Action::System(action) => match action { system::Action::QueryInformation(_tag) => { -- cgit From 2c2421ae5dad9afce1058e67ae8bcabd787fa373 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 17 Feb 2023 13:47:46 +0100 Subject: Expose `fetch_id` helper in `window` module --- winit/src/window.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'winit/src') diff --git a/winit/src/window.rs b/winit/src/window.rs index 3d5a765b..961562bd 100644 --- a/winit/src/window.rs +++ b/winit/src/window.rs @@ -95,3 +95,12 @@ pub fn change_always_on_top(on_top: bool) -> Command { on_top, ))) } + +/// Fetches an identifier unique to the window. +pub fn fetch_id( + f: impl FnOnce(u64) -> Message + 'static, +) -> Command { + Command::single(command::Action::Window(window::Action::FetchId(Box::new( + f, + )))) +} -- cgit From 0d1656937b459237670cdc0b1f45e09d78c47494 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 18 Feb 2023 12:04:40 +0100 Subject: Bump versions :tada: --- winit/src/conversion.rs | 12 ++++++------ winit/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'winit/src') diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index e83e55ec..1b2ead36 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.7/native +//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/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.7/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native pub fn mouse_interaction( interaction: mouse::Interaction, ) -> winit::window::CursorIcon { @@ -242,7 +242,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.7/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native pub fn mouse_button(mouse_button: winit::event::MouseButton) -> mouse::Button { match mouse_button { winit::event::MouseButton::Left => mouse::Button::Left, @@ -258,7 +258,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.7/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native pub fn modifiers( modifiers: winit::event::ModifiersState, ) -> keyboard::Modifiers { @@ -285,7 +285,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.7/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native pub fn touch_event( touch: winit::event::Touch, scale_factor: f64, @@ -316,7 +316,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.7/native +/// [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/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 c3172319..3a33e174 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.7/native +//! [`iced_native`]: https://github.com/iced-rs/iced/tree/0.8/native //! [`winit`]: https://github.com/rust-windowing/winit //! [`conversion`]: crate::conversion #![doc( -- cgit