Delay hiding git blame tooltip (#22644)

It's easy to overshoot the bottom of the tooltip when cursoring to a
button, such as opening the commit from a blame tooltip. Before this
change the tooltip would immediately disappear, and now it sticks around
for a bit.

Also:

* Shares the implementation with `elements/text.rs`. This will
particularly be handy when it makes use of hoverable tooltips.

* Improves the fix to #21657.

- Now the element will no longer think it has an active tooltip that it
registers with the window.

- It will instead display the next available tooltip, whereas I believe
before the next available tooltip would be suppressed.

* Fixes bug where `cx.refresh()` wasn't called when text tooltip is
hidden due to a mouse down event.

* Ports over fix in https://github.com/zed-industries/zed/pull/14832 to
`elements/text.rs`

Release Notes:

- The tooltip for inline git blame now waits a bit before disappearing
when the mouse leaves it.
This commit is contained in:
Michael Sloan 2025-01-18 13:52:14 -07:00 committed by GitHub
parent 985544ffb9
commit ac214c52c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 391 additions and 215 deletions

View file

@ -1635,11 +1635,10 @@ pub struct AnyTooltip {
/// The absolute position of the mouse when the tooltip was deployed.
pub mouse_position: Point<Pixels>,
/// Whether the tooltitp can be hovered or not.
pub hoverable: bool,
/// Bounds of the element that triggered the tooltip appearance.
pub origin_bounds: Bounds<Pixels>,
/// Given the bounds of the tooltip, checks whether the tooltip should still be visible and
/// updates its state accordingly. This is needed atop the hovered element's mouse move handler
/// to handle the case where the element is not painted (e.g. via use of `visible_on_hover`).
pub check_visible_and_update: Rc<dyn Fn(Bounds<Pixels>, &mut WindowContext) -> bool>,
}
/// A keystroke event, and potentially the associated action