diff --git a/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs index f2dd062a..a8dcdb20 100755 --- a/cosmic-app-list/src/app.rs +++ b/cosmic-app-list/src/app.rs @@ -223,6 +223,7 @@ enum Message { Favorite(String), UnFavorite(String), Popup(String), + CloseRequested(window::Id), ClosePopup, Activate(ZcosmicToplevelHandleV1), Exec(String), @@ -819,6 +820,11 @@ impl cosmic::Application for CosmicAppList { }) .collect(); } + Message::CloseRequested(id) => { + if Some(id) == self.popup.as_ref().map(|p| p.0) { + self.popup = None; + } + } } Command::none() @@ -1092,4 +1098,8 @@ impl cosmic::Application for CosmicAppList { fn style(&self) -> Option<::Style> { Some(cosmic::app::applet::style()) } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::CloseRequested(id)) + } } diff --git a/cosmic-applet-audio/src/main.rs b/cosmic-applet-audio/src/main.rs index 364d6738..61a4f840 100644 --- a/cosmic-applet-audio/src/main.rs +++ b/cosmic-applet-audio/src/main.rs @@ -124,6 +124,7 @@ enum Message { InputChanged(String), Pulse(pulse::Event), TogglePopup, + CloseRequested(window::Id), ToggleMediaControlsInTopPanel(chain::Toggler, bool), Frame(Instant), } @@ -317,6 +318,11 @@ impl cosmic::Application for Audio { self.timeline.set_chain(chain).start(); self.show_media_controls_in_top_panel = enabled; } + Message::CloseRequested(id) => { + if Some(id) == self.popup { + self.popup = None; + } + } }; Command::none() @@ -462,6 +468,10 @@ impl cosmic::Application for Audio { .popup_container(container(content)) .into() } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::CloseRequested(id)) + } } fn revealer( diff --git a/cosmic-applet-battery/src/app.rs b/cosmic-applet-battery/src/app.rs index 6dc6da17..322201a1 100644 --- a/cosmic-applet-battery/src/app.rs +++ b/cosmic-applet-battery/src/app.rs @@ -127,6 +127,7 @@ impl CosmicBatteryApplet { #[derive(Debug, Clone)] enum Message { TogglePopup, + CloseRequested(window::Id), Update { on_battery: bool, percent: f64, @@ -273,6 +274,11 @@ impl cosmic::Application for CosmicBatteryApplet { let _ = tx.send(PowerProfileRequest::Set(profile)); } } + Message::CloseRequested(id) => { + if Some(id) == self.popup { + self.popup = None; + } + } } Command::none() } @@ -467,6 +473,10 @@ impl cosmic::Application for CosmicBatteryApplet { ]) } + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::CloseRequested(id)) + } + fn style(&self) -> Option<::Style> { Some(cosmic::app::applet::style()) } diff --git a/cosmic-applet-bluetooth/src/app.rs b/cosmic-applet-bluetooth/src/app.rs index 794ab503..032dba8b 100644 --- a/cosmic-applet-bluetooth/src/app.rs +++ b/cosmic-applet-bluetooth/src/app.rs @@ -56,6 +56,7 @@ impl CosmicBluetoothApplet { #[derive(Debug, Clone)] enum Message { TogglePopup, + CloseRequested(window::Id), ToggleVisibleDevices(bool), Ignore, BluetoothEvent(BluerEvent), @@ -270,6 +271,11 @@ impl cosmic::Application for CosmicBluetoothApplet { ); } } + Message::CloseRequested(id) => { + if Some(id) == self.popup { + self.popup = None; + } + } } self.update_icon(); Command::none() @@ -524,4 +530,8 @@ impl cosmic::Application for CosmicBluetoothApplet { fn style(&self) -> Option<::Style> { Some(cosmic::app::applet::style()) } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::CloseRequested(id)) + } } diff --git a/cosmic-applet-graphics/src/window.rs b/cosmic-applet-graphics/src/window.rs index 1c4a559c..89ca01ea 100644 --- a/cosmic-applet-graphics/src/window.rs +++ b/cosmic-applet-graphics/src/window.rs @@ -412,4 +412,8 @@ impl cosmic::Application for Window { fn style(&self) -> Option<::Style> { Some(cosmic::app::applet::style()) } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::PopupClosed(id)) + } } diff --git a/cosmic-applet-network/src/app.rs b/cosmic-applet-network/src/app.rs index f7cba6b2..be5c5857 100644 --- a/cosmic-applet-network/src/app.rs +++ b/cosmic-applet-network/src/app.rs @@ -169,6 +169,7 @@ pub(crate) enum Message { ActivateKnownWifi(String), Disconnect(String), TogglePopup, + CloseRequested(window::Id), ToggleAirplaneMode(bool), ToggleWiFi(bool), ToggleVisibleNetworks, @@ -386,6 +387,11 @@ impl cosmic::Application for CosmicNetworkApplet { }; let _ = tx.unbounded_send(NetworkManagerRequest::Disconnect(ssid)); } + Message::CloseRequested(id) => { + if Some(id) == self.popup { + self.popup = None; + } + } } Command::none() } @@ -784,4 +790,8 @@ impl cosmic::Application for CosmicNetworkApplet { fn style(&self) -> Option<::Style> { Some(cosmic::app::applet::style()) } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::CloseRequested(id)) + } } diff --git a/cosmic-applet-notifications/src/main.rs b/cosmic-applet-notifications/src/main.rs index f4abf13d..37fb6836 100644 --- a/cosmic-applet-notifications/src/main.rs +++ b/cosmic-applet-notifications/src/main.rs @@ -84,6 +84,7 @@ impl Notifications { #[derive(Debug, Clone)] enum Message { TogglePopup, + CloseRequested(window::Id), DoNotDisturb(chain::Toggler, bool), Settings, Frame(Instant), @@ -296,6 +297,11 @@ impl cosmic::Application for Notifications { }; self.update_cards(id); } + Message::CloseRequested(id) => { + if Some(id) == self.popup { + self.popup = None; + } + } }; self.update_icon(); Command::none() @@ -486,6 +492,10 @@ impl cosmic::Application for Notifications { self.core.applet_helper.popup_container(content).into() } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::CloseRequested(id)) + } } // todo put into libcosmic doing so will fix the row_button's border radius diff --git a/cosmic-applet-time/src/main.rs b/cosmic-applet-time/src/main.rs index 3f7ac3a1..cd26611f 100644 --- a/cosmic-applet-time/src/main.rs +++ b/cosmic-applet-time/src/main.rs @@ -40,6 +40,7 @@ enum Every { #[derive(Debug, Clone)] enum Message { TogglePopup, + CloseRequested(window::Id), Tick, Rectangle(RectangleUpdate), } @@ -163,6 +164,12 @@ impl cosmic::Application for Time { } Command::none() } + Message::CloseRequested(id) => { + if Some(id) == self.popup { + self.popup = None; + } + Command::none() + } } } @@ -219,4 +226,8 @@ impl cosmic::Application for Time { self.core.applet_helper.popup_container(content).into() } + + fn on_close_requested(&self, id: window::Id) -> Option { + Some(Message::CloseRequested(id)) + } }