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.
This commit is contained in:
Ian Douglas Scott 2023-08-24 17:36:45 -07:00 committed by Ashley Wulber
parent 28446a33ab
commit f4cc4cecd0

View file

@ -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<Message> {
Some(Message::Closed(id))
}
}
// ### UI Helplers