From 6e97595d953811fe3f5877e13022c3b5d3b070a6 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Fri, 24 Nov 2023 16:08:03 +0800 Subject: feat: somewhere to place extra actions by platform I have view iced-sckt forked iced, and add the extra actions. and there do are some extra actions, like set margin for layer-shell, set lock for ext-session-shell. I think add an any will be of help maybe --- runtime/src/command/action.rs | 6 ++++++ winit/src/application.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/runtime/src/command/action.rs b/runtime/src/command/action.rs index cb0936df..d119141b 100644 --- a/runtime/src/command/action.rs +++ b/runtime/src/command/action.rs @@ -5,6 +5,7 @@ use crate::system; use crate::window; use iced_futures::MaybeSend; +use std::any::Any; use std::borrow::Cow; use std::fmt; @@ -43,6 +44,9 @@ pub enum Action { /// The message to produce when the font has been loaded. tagger: Box) -> T>, }, + + /// Pass PlatformSpecific action, for some special platform + PlatformSpecific(Box) } impl Action { @@ -72,6 +76,7 @@ impl Action { bytes, tagger: Box::new(move |result| f(tagger(result))), }, + Self::PlatformSpecific(special) => Action::PlatformSpecific(special) } } } @@ -90,6 +95,7 @@ impl fmt::Debug for Action { Self::System(action) => write!(f, "Action::System({action:?})"), Self::Widget(_action) => write!(f, "Action::Widget"), Self::LoadFont { .. } => write!(f, "Action::LoadFont"), + Self::PlatformSpecific(_) => write!(f, "Action::PlatformSpecific") } } } diff --git a/winit/src/application.rs b/winit/src/application.rs index 21a985e8..e44b3ca5 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -861,6 +861,7 @@ pub fn run_command( .send_event(tagger(Ok(()))) .expect("Send message to event loop"); } + command::Action::PlatformSpecific(_) => unimplemented!(), } } } -- cgit From 26569069038d60c05e935c45d34cc5c8099c798f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Feb 2024 15:10:45 +0100 Subject: Rename `PlateformSpecific` variant in `Action` to `Custom` --- runtime/src/command/action.rs | 8 ++++---- winit/src/application.rs | 4 +++- winit/src/multi_window.rs | 3 +++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/runtime/src/command/action.rs b/runtime/src/command/action.rs index d119141b..4592df5d 100644 --- a/runtime/src/command/action.rs +++ b/runtime/src/command/action.rs @@ -45,8 +45,8 @@ pub enum Action { tagger: Box) -> T>, }, - /// Pass PlatformSpecific action, for some special platform - PlatformSpecific(Box) + /// A custom action supported by a specific runtime. + Custom(Box), } impl Action { @@ -76,7 +76,7 @@ impl Action { bytes, tagger: Box::new(move |result| f(tagger(result))), }, - Self::PlatformSpecific(special) => Action::PlatformSpecific(special) + Self::Custom(custom) => Action::Custom(custom), } } } @@ -95,7 +95,7 @@ impl fmt::Debug for Action { Self::System(action) => write!(f, "Action::System({action:?})"), Self::Widget(_action) => write!(f, "Action::Widget"), Self::LoadFont { .. } => write!(f, "Action::LoadFont"), - Self::PlatformSpecific(_) => write!(f, "Action::PlatformSpecific") + Self::Custom(_) => write!(f, "Action::Custom"), } } } diff --git a/winit/src/application.rs b/winit/src/application.rs index e44b3ca5..24c98d46 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -861,7 +861,9 @@ pub fn run_command( .send_event(tagger(Ok(()))) .expect("Send message to event loop"); } - command::Action::PlatformSpecific(_) => unimplemented!(), + command::Action::Custom(_) => { + log::warn!("Unsupported custom action in `iced_winit` shell"); + } } } } diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index 1c45ce37..662adf5b 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -1127,6 +1127,9 @@ fn run_command( .send_event(tagger(Ok(()))) .expect("Send message to event loop"); } + command::Action::Custom(_) => { + log::warn!("Unsupported custom action in `iced_winit` shell"); + } } } } -- cgit From ece50a1a954baabcd80762e56396906eac6cb975 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Feb 2024 15:12:07 +0100 Subject: Organize imports in `runtime::command::action` --- runtime/src/command/action.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/runtime/src/command/action.rs b/runtime/src/command/action.rs index 4592df5d..c9ffe801 100644 --- a/runtime/src/command/action.rs +++ b/runtime/src/command/action.rs @@ -1,12 +1,11 @@ use crate::clipboard; use crate::core::widget; use crate::font; +use crate::futures::MaybeSend; use crate::system; use crate::window; -use iced_futures::MaybeSend; use std::any::Any; - use std::borrow::Cow; use std::fmt; -- cgit From 4375e4b83c6572e23db9f2443bbc7fe266f7e0a8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 3 Feb 2024 15:12:56 +0100 Subject: Update `CHANGELOG` --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4557f69..6690c0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `style` attribute for `Font`. [#2041](https://github.com/iced-rs/iced/pull/2041) - Texture filtering options for `Image`. [#1894](https://github.com/iced-rs/iced/pull/1894) - `default` and `shift_step` methods for `slider` widgets. [#2100](https://github.com/iced-rs/iced/pull/2100) +- `Custom` variant to `command::Action`. [#2146](https://github.com/iced-rs/iced/pull/2146) ### Changed - Enable WebGPU backend in `wgpu` by default instead of WebGL. [#2068](https://github.com/iced-rs/iced/pull/2068) @@ -101,6 +102,7 @@ Many thanks to... - @casperstorm - @cfrenette - @Davidster +- @Decodetalkers - @derezzedex - @dtzxporter - @GyulyVGC -- cgit