Skip to content

Commit 83f8c24

Browse files
committed
spawn with idle priority
1 parent bbca7a4 commit 83f8c24

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/widgets/window.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ impl<W: glib::IsA<gtk::Widget>> SpawnWithToast for W {
3030
.ancestor(adw::ToastOverlay::static_type())
3131
.and_downcast();
3232
let win: Option<NotifyWindow> = self.ancestor(NotifyWindow::static_type()).and_downcast();
33-
glib::MainContext::default().spawn_local(async move {
34-
if let Err(e) = f.await {
35-
if let Some(o) = toast_overlay
36-
.as_ref()
37-
.or_else(|| win.as_ref().map(|win| win.imp().toast_overlay.as_ref()))
38-
{
39-
o.add_toast(adw::Toast::builder().title(&e.to_string()).build())
33+
glib::MainContext::ref_thread_default().spawn_local_with_priority(
34+
glib::Priority::DEFAULT_IDLE,
35+
async move {
36+
if let Err(e) = f.await {
37+
if let Some(o) = toast_overlay
38+
.as_ref()
39+
.or_else(|| win.as_ref().map(|win| win.imp().toast_overlay.as_ref()))
40+
{
41+
o.add_toast(adw::Toast::builder().title(&e.to_string()).build())
42+
}
4043
}
41-
}
42-
});
44+
},
45+
);
4346
}
4447
}
4548

0 commit comments

Comments
 (0)