feat: avoid tooltip creation if there is an existing popup
This commit is contained in:
parent
0aed003d09
commit
bc0b52ed5f
4 changed files with 78 additions and 66 deletions
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ where
|
|||
iced_winit::commands::popup::get_popup(settings())
|
||||
}
|
||||
}
|
||||
SurfaceMessage::Ignore => iced::Task::none(),
|
||||
}
|
||||
#[cfg(not(feature = "wayland"))]
|
||||
iced::Task::none()
|
||||
|
|
|
|||
|
|
@ -238,8 +238,9 @@ impl Context {
|
|||
&self,
|
||||
content: impl Into<Element<'a, Message>>,
|
||||
tooltip: impl Into<Cow<'static, str>>,
|
||||
has_popup: bool,
|
||||
) -> 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 anchor = self.anchor;
|
||||
let tooltip = tooltip.into();
|
||||
|
|
@ -254,7 +255,9 @@ impl Context {
|
|||
PanelAnchor::Top => (Anchor::Bottom, Gravity::Bottom),
|
||||
PanelAnchor::Bottom => (Anchor::Top, Gravity::Top),
|
||||
};
|
||||
|
||||
if has_popup {
|
||||
SurfaceMessage::Ignore.into()
|
||||
} else {
|
||||
crate::app::message::simple_popup::<
|
||||
Message,
|
||||
Option<
|
||||
|
|
@ -298,6 +301,7 @@ impl Context {
|
|||
))
|
||||
})),
|
||||
)
|
||||
}
|
||||
};
|
||||
crate::widget::wayland::tooltip::widget::Tooltip::new(
|
||||
content,
|
||||
|
|
|
|||
|
|
@ -50,14 +50,17 @@ pub enum SurfaceMessage {
|
|||
/// Requested Full Size for expanded menu bar
|
||||
size: Size,
|
||||
},
|
||||
Ignore,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for SurfaceMessage {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::AppSubsurface(arg0, arg1) => {
|
||||
f.debug_tuple("Subsurface").field(arg0).field(arg1).finish()
|
||||
}
|
||||
Self::AppSubsurface(arg0, arg1) => f
|
||||
.debug_tuple("AppSubsurface")
|
||||
.field(arg0)
|
||||
.field(arg1)
|
||||
.finish(),
|
||||
Self::Subsurface(arg0, arg1) => {
|
||||
f.debug_tuple("Subsurface").field(arg0).field(arg1).finish()
|
||||
}
|
||||
|
|
@ -79,6 +82,7 @@ impl std::fmt::Debug for SurfaceMessage {
|
|||
.field("limits", limits)
|
||||
.field("size", size)
|
||||
.finish(),
|
||||
Self::Ignore => write!(f, "Ignore"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue