From 58f4e29679e25a031133bfc145ae7a3f034efd9c Mon Sep 17 00:00:00 2001 From: Maximiliano Sandoval R Date: Thu, 5 Oct 2023 22:01:36 +0200 Subject: [PATCH] window: Ask portal only once the window is mapped Otherwise the shell will reject the permission. --- src/widgets/window.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/widgets/window.rs b/src/widgets/window.rs index 8ec35fc3..397da532 100644 --- a/src/widgets/window.rs +++ b/src/widgets/window.rs @@ -165,15 +165,20 @@ mod imp { let enabled = navigation_view.visible_page().is_some_and(|page| &page == &*imp.camera_page); obj.set_shutter_enabled(enabled); })); + } + } + impl WidgetImpl for Window { + fn map(&self) { + self.parent_map(); + let camera = self.camera.get(); let ctx = glib::MainContext::default(); - ctx.spawn_local(glib::clone!(@weak obj => async move { - obj.imp().camera.start().await; + ctx.spawn_local(glib::clone!(@weak camera => async move { + camera.start().await; })); } } - impl WidgetImpl for Window {} impl WindowImpl for Window { // Save window state on delete event fn close_request(&self) -> glib::Propagation { -- GitLab