track surfaces that use a normal view method
This commit is contained in:
parent
cadb773377
commit
732785a50c
5 changed files with 361 additions and 47 deletions
|
|
@ -28,6 +28,12 @@ pub fn destroy_window(id: iced_core::window::Id) -> Action {
|
|||
Action::DestroyWindow(id)
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "wayland", target_os = "linux"))]
|
||||
#[must_use]
|
||||
pub fn destroy_layer_shell(id: iced_core::window::Id) -> Action {
|
||||
Action::DestroyLayerShell(id)
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))]
|
||||
#[must_use]
|
||||
pub fn app_window<App: Application>(
|
||||
|
|
@ -226,3 +232,76 @@ pub fn subsurface<App: Application>(
|
|||
}),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))]
|
||||
#[must_use]
|
||||
pub fn simple_layer_shell<Message: 'static>(
|
||||
settings: impl Fn()
|
||||
-> iced_runtime::platform_specific::wayland::layer_surface::SctkLayerSurfaceSettings
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
view: Option<
|
||||
impl Fn() -> crate::Element<'static, crate::Action<Message>> + Send + Sync + 'static,
|
||||
>,
|
||||
) -> Action {
|
||||
let boxed: Box<
|
||||
dyn Fn()
|
||||
-> iced_runtime::platform_specific::wayland::layer_surface::SctkLayerSurfaceSettings
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
> = Box::new(settings);
|
||||
let boxed: Box<dyn Any + Send + Sync + 'static> = Box::new(boxed);
|
||||
|
||||
Action::LayerShell(
|
||||
Arc::new(boxed),
|
||||
view.map(|view| {
|
||||
let boxed: Box<
|
||||
dyn Fn() -> crate::Element<'static, crate::Action<Message>> + Send + Sync + 'static,
|
||||
> = Box::new(view);
|
||||
let boxed: Box<dyn Any + Send + Sync + 'static> = Box::new(boxed);
|
||||
Arc::new(boxed)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "wayland", target_os = "linux", feature = "winit"))]
|
||||
#[must_use]
|
||||
pub fn layer_shell<App: Application>(
|
||||
settings: impl Fn(
|
||||
&mut App,
|
||||
)
|
||||
-> iced_runtime::platform_specific::wayland::layer_surface::SctkLayerSurfaceSettings
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
// XXX Boxed trait object is required for less cumbersome type inference, but we box it anyways.
|
||||
view: Option<
|
||||
Box<
|
||||
dyn for<'a> Fn(&'a App) -> crate::Element<'a, crate::Action<App::Message>>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
>,
|
||||
>,
|
||||
) -> Action {
|
||||
let boxed: Box<
|
||||
dyn Fn(
|
||||
&mut App,
|
||||
)
|
||||
-> iced_runtime::platform_specific::wayland::layer_surface::SctkLayerSurfaceSettings
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
> = Box::new(settings);
|
||||
let boxed: Box<dyn Any + Send + Sync + 'static> = Box::new(boxed);
|
||||
|
||||
Action::AppLayerShell(
|
||||
Arc::new(boxed),
|
||||
view.map(|view| {
|
||||
let boxed: Box<dyn Any + Send + Sync + 'static> = Box::new(view);
|
||||
Arc::new(boxed)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,21 @@ pub enum Action {
|
|||
/// Destroy a window
|
||||
DestroyWindow(iced::window::Id),
|
||||
|
||||
/// Create a layer shell surface with a view function accepting the App as a parameter
|
||||
AppLayerShell(
|
||||
std::sync::Arc<Box<dyn std::any::Any + Send + Sync>>,
|
||||
Option<std::sync::Arc<Box<dyn std::any::Any + Send + Sync>>>,
|
||||
),
|
||||
|
||||
/// Create a layer shell surface with a view function
|
||||
LayerShell(
|
||||
std::sync::Arc<Box<dyn std::any::Any + Send + Sync>>,
|
||||
Option<std::sync::Arc<Box<dyn std::any::Any + Send + Sync>>>,
|
||||
),
|
||||
|
||||
/// Destroy a layer shell surface
|
||||
DestroyLayerShell(iced::window::Id),
|
||||
|
||||
/// Responsive menu bar update
|
||||
ResponsiveMenuBar {
|
||||
/// Id of the menu bar
|
||||
|
|
@ -111,6 +126,18 @@ impl std::fmt::Debug for Action {
|
|||
.finish(),
|
||||
Self::DestroyWindow(arg0) => f.debug_tuple("DestroyWindow").field(arg0).finish(),
|
||||
Self::Task(_) => f.debug_tuple("Future").finish(),
|
||||
Self::AppLayerShell(any, any1) => f
|
||||
.debug_tuple("AppLayerShell")
|
||||
.field(any)
|
||||
.field(any1)
|
||||
.finish(),
|
||||
Self::LayerShell(any, any1) => {
|
||||
f.debug_tuple("LayerShell").field(any).field(any1).finish()
|
||||
}
|
||||
Self::DestroyLayerShell(arg0) => {
|
||||
f.debug_tuple("DestroyLayerShell").field(arg0).finish()
|
||||
}
|
||||
Self::Task(_) => f.debug_tuple("Task").finish(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue