Skip to content

Commit

Permalink
feat: somewhere to place extra actions by platform
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Decodetalkers committed Nov 24, 2023
1 parent 751ea77 commit 6a6a25b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions runtime/src/command/action.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -38,6 +39,9 @@ pub enum Action<T> {
/// The message to produce when the font has been loaded.
tagger: Box<dyn Fn(Result<(), font::Error>) -> T>,
},

/// Pass PlatformSpecific action, for some special platform
PlatformSpecific(Box<dyn Any>)
}

impl<T> Action<T> {
Expand Down Expand Up @@ -66,6 +70,7 @@ impl<T> Action<T> {
bytes,
tagger: Box::new(move |result| f(tagger(result))),
},
Self::PlatformSpecific(special) => Action::PlatformSpecific(special)
}
}
}
Expand All @@ -81,6 +86,7 @@ impl<T> fmt::Debug for Action<T> {
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")
}
}
}
1 change: 1 addition & 0 deletions winit/src/application.rs
Expand Up @@ -904,6 +904,7 @@ pub fn run_command<A, C, E>(
.send_event(tagger(Ok(())))
.expect("Send message to event loop");
}
command::Action::PlatformSpecific(_) => unimplemented!(),
}
}
}
Expand Down

0 comments on commit 6a6a25b

Please sign in to comment.