only countdown when there's a confirm popup

Co-authored-by: Ashley Wulber <48420062+wash2@users.noreply.github.com>
This commit is contained in:
PixelDoted 2023-10-31 11:51:38 -05:00 committed by Ashley Wulber
parent 2882286de6
commit 2c9470bdd7

View file

@ -109,18 +109,18 @@ impl cosmic::Application for Power {
}
fn subscription(&self) -> Subscription<Message> {
Subscription::batch(vec![
events_with(|e, _status| match e {
cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Layer(LayerEvent::Unfocused, ..),
)) => Some(Message::Cancel),
// cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
// wayland::Event::Seat(wayland::SeatEvent::Leave, _),
// )) => Some(Message::Cancel),
_ => None,
}),
time::every(Duration::from_millis(1000)).map(|_| Message::Countdown),
])
let mut subscriptions = Vec::with_capacity(2);
subscriptions.push(events_with(|e, _status| match e {
cosmic::iced::Event::PlatformSpecific(PlatformSpecific::Wayland(
wayland::Event::Layer(LayerEvent::Unfocused, ..),
)) => Some(Message::Cancel),
_ => None,
}));
if self.action_to_confirm.is_some() {
subscriptions
.push(time::every(Duration::from_millis(1000)).map(|_| Message::Countdown));
}
Subscription::batch(subscriptions)
}
fn update(&mut self, message: Message) -> Command<Message> {