feat: avoid tooltip creation if there is an existing popup
This commit is contained in:
parent
40748c3037
commit
8b5d5ee45c
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> {
|
fn view_window(&self, _id: Id) -> Element<Self::Message> {
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue