Skip to content

Commit 3e710ff

Browse files
committed
feat(applets): add destroy tooltip popup action
This commit adds a new surface action to explicitly destroy the tooltip popup on `TOOLTIP_WINDOW_ID`, allowing proper cleanup when minimizing applets.
1 parent d7fd880 commit 3e710ff

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/app/cosmic.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ where
230230
iced_winit::commands::popup::destroy_popup(id)
231231
}
232232
#[cfg(feature = "wayland")]
233+
crate::surface::Action::DestroyTooltipPopup => {
234+
#[cfg(feature = "applet")]
235+
{
236+
iced_winit::commands::popup::destroy_popup(*crate::applet::TOOLTIP_WINDOW_ID)
237+
}
238+
#[cfg(not(feature = "applet"))]
239+
{
240+
Task::none()
241+
}
242+
}
243+
#[cfg(feature = "wayland")]
233244
crate::surface::Action::DestroySubsurface(id) => {
234245
iced_winit::commands::subsurface::destroy_subsurface(id)
235246
}

src/applet/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static AUTOSIZE_ID: LazyLock<iced::id::Id> =
4242
static AUTOSIZE_MAIN_ID: LazyLock<iced::id::Id> =
4343
LazyLock::new(|| iced::id::Id::new("cosmic-applet-autosize-main"));
4444
static TOOLTIP_ID: LazyLock<crate::widget::Id> = LazyLock::new(|| iced::id::Id::new("subsurface"));
45-
static TOOLTIP_WINDOW_ID: LazyLock<window::Id> = LazyLock::new(window::Id::unique);
45+
pub(crate) static TOOLTIP_WINDOW_ID: LazyLock<window::Id> = LazyLock::new(window::Id::unique);
4646

4747
#[derive(Debug, Clone)]
4848
pub struct Context {

src/surface/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ pub enum Action {
3636
),
3737
/// Destroy a subsurface with a view function
3838
DestroyPopup(iced::window::Id),
39+
/// Destroys the global tooltip popup subsurface
40+
DestroyTooltipPopup,
3941

4042
/// Create a window with a view function accepting the App as a parameter
4143
AppWindow(
@@ -85,6 +87,7 @@ impl std::fmt::Debug for Action {
8587
}
8688
Self::Popup(arg0, arg1) => f.debug_tuple("Popup").field(arg0).field(arg1).finish(),
8789
Self::DestroyPopup(arg0) => f.debug_tuple("DestroyPopup").field(arg0).finish(),
90+
Self::DestroyTooltipPopup => f.debug_tuple("DestroyTooltipPopup").finish(),
8891
Self::ResponsiveMenuBar {
8992
menu_bar,
9093
limits,

0 commit comments

Comments
 (0)