Remove stuck tooltips (#22548)
Closes https://github.com/zed-industries/zed/issues/21657 Follow-up of https://github.com/zed-industries/zed/pull/22488 Previous PR broke git blame tooltips, which are expected to be open when hovered, even if the mouse cursor is moved away from the actual blame entry that caused the tooltip to appear. Current version moves the invalidation logic into `prepaint_tooltip`, where the new data about the tooltip origin is used to ensure we invalidate only tooltips that have no mouse cursor in either origin bounds or tooltip bounds (if it's hoverable). Release Notes: - Fixed tooltips getting stuck
This commit is contained in:
parent
0d423a7b37
commit
c11bde7bf4
4 changed files with 28 additions and 3 deletions
|
@ -1557,6 +1557,19 @@ impl<'a> WindowContext<'a> {
|
|||
let tooltip_size = element.layout_as_root(AvailableSpace::min_size(), self);
|
||||
|
||||
let mut tooltip_bounds = Bounds::new(mouse_position + point(px(1.), px(1.)), tooltip_size);
|
||||
// Element's parent can get hidden (e.g. via the `visible_on_hover` method),
|
||||
// and element's `paint` won't be called (ergo, mouse listeners also won't be active) to detect that the tooltip has to be removed.
|
||||
// Ensure it's not stuck around in such cases.
|
||||
let invalidate_tooltip = !tooltip_request
|
||||
.tooltip
|
||||
.origin_bounds
|
||||
.contains(&self.mouse_position())
|
||||
&& (!tooltip_request.tooltip.hoverable
|
||||
|| !tooltip_bounds.contains(&self.mouse_position()));
|
||||
if invalidate_tooltip {
|
||||
return None;
|
||||
}
|
||||
|
||||
let window_bounds = Bounds {
|
||||
origin: Point::default(),
|
||||
size: self.viewport_size(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue