refactor: better tooltips and helper methods for managing subsurfaces/popups
This commit is contained in:
parent
41bd495a56
commit
6f643d1d3a
7 changed files with 255 additions and 125 deletions
|
|
@ -130,7 +130,7 @@ where
|
|||
MessageWrapper::Surface(surface_message) => {
|
||||
#[cfg(feature = "wayland")]
|
||||
match surface_message {
|
||||
SurfaceMessage::Subsurface(settings, view) => {
|
||||
SurfaceMessage::AppSubsurface(settings, view) => {
|
||||
let Some(settings) = std::sync::Arc::try_unwrap(settings)
|
||||
.ok()
|
||||
.and_then(|s| s.downcast::<Box<dyn Fn(&mut T) -> iced_runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings + Send + Sync>>().ok()) else {
|
||||
|
|
@ -150,6 +150,7 @@ where
|
|||
tracing::error!(
|
||||
"Invalid view for subsurface view: {err:?}"
|
||||
);
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
@ -162,6 +163,38 @@ where
|
|||
))
|
||||
}
|
||||
}
|
||||
SurfaceMessage::Subsurface(settings, view) => {
|
||||
let Some(settings) = std::sync::Arc::try_unwrap(settings)
|
||||
.ok()
|
||||
.and_then(|s| s.downcast::<Box<dyn Fn() -> iced_runtime::platform_specific::wayland::subsurface::SctkSubsurfaceSettings + Send + Sync>>().ok()) else {
|
||||
tracing::error!("Invalid settings for subsurface");
|
||||
return Task::none();
|
||||
};
|
||||
|
||||
if let Some(view) = view.and_then(|view| {
|
||||
match std::sync::Arc::try_unwrap(view).ok()?.downcast::<Box<
|
||||
dyn Fn() -> Element<'static, super::Message<T::Message>>
|
||||
+ Send
|
||||
+ Sync,
|
||||
>>(
|
||||
) {
|
||||
Ok(v) => Some(v),
|
||||
Err(err) => {
|
||||
tracing::error!(
|
||||
"Invalid view for subsurface view: {err:?}"
|
||||
);
|
||||
dbg!("bad view");
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
}) {
|
||||
let settings = settings();
|
||||
self.get_subsurface(settings, Box::new(move |_| view()))
|
||||
} else {
|
||||
iced_winit::commands::subsurface::get_subsurface(settings())
|
||||
}
|
||||
}
|
||||
SurfaceMessage::AppPopup(settings, view) => {
|
||||
let Some(settings) = std::sync::Arc::try_unwrap(settings)
|
||||
.ok()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue