fix: surface cleanup
Clean up surfaces before processing the dialog result message
This commit is contained in:
parent
2c7d06c980
commit
b571f11b92
1 changed files with 37 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ use cosmic::{
|
||||||
stream, window,
|
stream, window,
|
||||||
},
|
},
|
||||||
iced_core::widget::operation,
|
iced_core::widget::operation,
|
||||||
|
iced_winit::{self, SurfaceIdWrapper},
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
self, Operation,
|
self, Operation,
|
||||||
|
|
@ -368,7 +369,43 @@ impl<M: Send + 'static> Dialog<M> {
|
||||||
.map(DialogMessage)
|
.map(DialogMessage)
|
||||||
.map(move |message| cosmic::action::app(mapper(message)));
|
.map(move |message| cosmic::action::app(mapper(message)));
|
||||||
if let Some(result) = self.cosmic.app.result_opt.take() {
|
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);
|
let on_result_message = (self.on_result)(result);
|
||||||
|
|
||||||
Task::batch([
|
Task::batch([
|
||||||
command,
|
command,
|
||||||
Task::future(async move { cosmic::action::app(on_result_message) }),
|
Task::future(async move { cosmic::action::app(on_result_message) }),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue