Hide the mouse when the user is typing in the editor - take 2 (#27519)
Closes #4461 Take 2 on https://github.com/zed-industries/zed/pull/25040. Fixes panic caused due to using `setHiddenUntilMouseMoves` return type to `set` cursor on macOS. Release Notes: - Now cursor hides when the user is typing in editor. It will stay hidden until it is moved again. This behavior is `true` by default, and can be configured with `hide_mouse_while_typing` in settings. --------- Co-authored-by: Peter Tripp <peter@zed.dev> Co-authored-by: Thomas Mickley-Doyle <thomas@zed.dev> Co-authored-by: Agus <agus@zed.dev> Co-authored-by: Kirill Bulatov <kirill@zed.dev> Co-authored-by: Agus Zubiaga <hi@aguz.me> Co-authored-by: Angelk90 <angelo.k90@hotmail.it>
This commit is contained in:
parent
848a99c605
commit
77856bf017
25 changed files with 172 additions and 52 deletions
|
@ -407,7 +407,7 @@ pub(crate) type AnyMouseListener =
|
|||
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct CursorStyleRequest {
|
||||
pub(crate) hitbox_id: HitboxId,
|
||||
pub(crate) hitbox_id: Option<HitboxId>, // None represents whole window
|
||||
pub(crate) style: CursorStyle,
|
||||
}
|
||||
|
||||
|
@ -1928,10 +1928,10 @@ impl Window {
|
|||
|
||||
/// Updates the cursor style at the platform level. This method should only be called
|
||||
/// during the prepaint phase of element drawing.
|
||||
pub fn set_cursor_style(&mut self, style: CursorStyle, hitbox: &Hitbox) {
|
||||
pub fn set_cursor_style(&mut self, style: CursorStyle, hitbox: Option<&Hitbox>) {
|
||||
self.invalidator.debug_assert_paint();
|
||||
self.next_frame.cursor_styles.push(CursorStyleRequest {
|
||||
hitbox_id: hitbox.id,
|
||||
hitbox_id: hitbox.map(|hitbox| hitbox.id),
|
||||
style,
|
||||
});
|
||||
}
|
||||
|
@ -2984,7 +2984,11 @@ impl Window {
|
|||
.cursor_styles
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|request| request.hitbox_id.is_hovered(self))
|
||||
.find(|request| {
|
||||
request
|
||||
.hitbox_id
|
||||
.map_or(true, |hitbox_id| hitbox_id.is_hovered(self))
|
||||
})
|
||||
.map(|request| request.style)
|
||||
.unwrap_or(CursorStyle::Arrow);
|
||||
cx.platform.set_cursor_style(style);
|
||||
|
@ -3241,6 +3245,7 @@ impl Window {
|
|||
keystroke,
|
||||
&dispatch_path,
|
||||
);
|
||||
|
||||
if !match_result.to_replay.is_empty() {
|
||||
self.replay_pending_input(match_result.to_replay, cx)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue