From f4cc4cecd07f8fab78f98b8b3f7e51535d7a04de Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 24 Aug 2023 17:36:45 -0700 Subject: [PATCH] Fix re-opening popup after it is dismissed by the compositor I noticed working on https://github.com/pop-os/cosmic-applets/pull/33 that https://github.com/pop-os/cosmic-applets/pull/110 seems to have broken the behavior here. After the popup is dismissed by the compositor, it requires two clicks to re-open instead of one. This change will need to be made to all the applets. --- cosmic-applet-power/src/main.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cosmic-applet-power/src/main.rs b/cosmic-applet-power/src/main.rs index 12742822..44f280b4 100644 --- a/cosmic-applet-power/src/main.rs +++ b/cosmic-applet-power/src/main.rs @@ -72,6 +72,7 @@ enum Message { Confirm, Cancel, Zbus(Result<(), zbus::Error>), + Closed(window::Id), } impl cosmic::Application for Power { @@ -211,6 +212,12 @@ impl cosmic::Application for Power { } Command::none() } + Message::Closed(id) => { + if self.popup == Some(id) { + self.popup = None; + } + Command::none() + } } } @@ -330,6 +337,10 @@ impl cosmic::Application for Power { widget::text("").into() } } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::Closed(id)) + } } // ### UI Helplers