Merge pull request #1381 from pop-os/contains-surface

Contains surface
This commit is contained in:
Jeremy Soller 2025-11-18 14:58:53 -07:00 committed by GitHub
commit 10b2bd7383
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,7 @@ use cosmic::{
stream, window,
},
iced_core::widget::operation,
iced_winit::{self, SurfaceIdWrapper},
theme,
widget::{
self, Operation,
@ -368,7 +369,43 @@ impl<M: Send + 'static> Dialog<M> {
.map(DialogMessage)
.map(move |message| cosmic::action::app(mapper(message)));
if let Some(result) = self.cosmic.app.result_opt.take() {
if !self.cosmic.surface_views.is_empty() {
log::debug!("waiting for surfaces to close...");
let mut tasks = Vec::new();
for id in self.cosmic.surface_views.drain() {
match id.1.1 {
SurfaceIdWrapper::Window(id) => {
tasks.push(window::close::<M>(id).discard());
}
SurfaceIdWrapper::LayerSurface(id) => {
tasks.push(iced_winit::wayland::commands::layer_surface::destroy_layer_surface::<M>(id).discard());
}
SurfaceIdWrapper::Popup(id) => {
tasks.push(
iced_winit::wayland::commands::popup::destroy_popup::<M>(id)
.discard(),
);
}
SurfaceIdWrapper::Subsurface(id) => {
tasks.push(
iced_winit::wayland::commands::subsurface::destroy_subsurface::<M>(
id,
)
.discard(),
);
}
_ => {}
}
}
let on_result_message = (self.on_result)(result);
tasks.push(Task::future(async move {
cosmic::action::app(on_result_message)
}));
return Task::batch(tasks);
}
let on_result_message = (self.on_result)(result);
Task::batch([
command,
Task::future(async move { cosmic::action::app(on_result_message) }),
@ -388,6 +425,10 @@ impl<M: Send + 'static> Dialog<M> {
pub const fn window_id(&self) -> window::Id {
self.cosmic.app.flags.window_id
}
pub fn contains_surface(&self, id: &window::Id) -> bool {
self.cosmic.surface_views.contains_key(id)
}
}
#[derive(Clone, Debug)]