feat: avoid tooltip creation if there is an existing popup

This commit is contained in:
Ashley Wulber 2025-02-27 14:54:03 -05:00
parent 0aed003d09
commit bc0b52ed5f
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
4 changed files with 78 additions and 66 deletions

View file

@ -210,7 +210,10 @@ impl cosmic::Application for Window {
}, },
); );
self.core.applet.applet_tooltip(btn, "test").into() self.core
.applet
.applet_tooltip(btn, "test", self.popup.is_some())
.into()
} }
fn view_window(&self, _id: Id) -> Element<Self::Message> { fn view_window(&self, _id: Id) -> Element<Self::Message> {

View file

@ -274,6 +274,7 @@ where
iced_winit::commands::popup::get_popup(settings()) iced_winit::commands::popup::get_popup(settings())
} }
} }
SurfaceMessage::Ignore => iced::Task::none(),
} }
#[cfg(not(feature = "wayland"))] #[cfg(not(feature = "wayland"))]
iced::Task::none() iced::Task::none()

View file

@ -238,8 +238,9 @@ impl Context {
&self, &self,
content: impl Into<Element<'a, Message>>, content: impl Into<Element<'a, Message>>,
tooltip: impl Into<Cow<'static, str>>, tooltip: impl Into<Cow<'static, str>>,
has_popup: bool,
) -> crate::widget::wayland::tooltip::widget::Tooltip<'a, Message> { ) -> crate::widget::wayland::tooltip::widget::Tooltip<'a, Message> {
let window_id = TOOLTIP_WINDOW_ID.clone(); let window_id = *TOOLTIP_WINDOW_ID;
let subsurface_id = TOOLTIP_ID.clone(); let subsurface_id = TOOLTIP_ID.clone();
let anchor = self.anchor; let anchor = self.anchor;
let tooltip = tooltip.into(); let tooltip = tooltip.into();
@ -254,7 +255,9 @@ impl Context {
PanelAnchor::Top => (Anchor::Bottom, Gravity::Bottom), PanelAnchor::Top => (Anchor::Bottom, Gravity::Bottom),
PanelAnchor::Bottom => (Anchor::Top, Gravity::Top), PanelAnchor::Bottom => (Anchor::Top, Gravity::Top),
}; };
if has_popup {
SurfaceMessage::Ignore.into()
} else {
crate::app::message::simple_popup::< crate::app::message::simple_popup::<
Message, Message,
Option< Option<
@ -298,6 +301,7 @@ impl Context {
)) ))
})), })),
) )
}
}; };
crate::widget::wayland::tooltip::widget::Tooltip::new( crate::widget::wayland::tooltip::widget::Tooltip::new(
content, content,

View file

@ -50,14 +50,17 @@ pub enum SurfaceMessage {
/// Requested Full Size for expanded menu bar /// Requested Full Size for expanded menu bar
size: Size, size: Size,
}, },
Ignore,
} }
impl std::fmt::Debug for SurfaceMessage { impl std::fmt::Debug for SurfaceMessage {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::AppSubsurface(arg0, arg1) => { Self::AppSubsurface(arg0, arg1) => f
f.debug_tuple("Subsurface").field(arg0).field(arg1).finish() .debug_tuple("AppSubsurface")
} .field(arg0)
.field(arg1)
.finish(),
Self::Subsurface(arg0, arg1) => { Self::Subsurface(arg0, arg1) => {
f.debug_tuple("Subsurface").field(arg0).field(arg1).finish() f.debug_tuple("Subsurface").field(arg0).field(arg1).finish()
} }
@ -79,6 +82,7 @@ impl std::fmt::Debug for SurfaceMessage {
.field("limits", limits) .field("limits", limits)
.field("size", size) .field("size", size)
.finish(), .finish(),
Self::Ignore => write!(f, "Ignore"),
} }
} }
} }