input: Hide cursor and selection when window is deactivated. (#1066)

This commit is contained in:
Jason Lee 2025-07-16 14:01:46 +08:00 committed by GitHub
parent eca7949583
commit ea1f5331c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -900,8 +900,10 @@ impl Element for TextElement {
}
// Paint selections
if let Some(path) = prepaint.selection_path.take() {
window.paint_path(path, cx.theme().selection);
if window.is_window_active() {
if let Some(path) = prepaint.selection_path.take() {
window.paint_path(path, cx.theme().selection);
}
}
// Paint text

View file

@ -1963,7 +1963,9 @@ impl InputState {
/// Returns the true to let InputElement to render cursor, when Input is focused and current BlinkCursor is visible.
pub(crate) fn show_cursor(&self, window: &Window, cx: &App) -> bool {
self.focus_handle.is_focused(window) && self.blink_cursor.read(cx).visible()
self.focus_handle.is_focused(window)
&& self.blink_cursor.read(cx).visible()
&& window.is_window_active()
}
fn on_focus(&mut self, _: &mut Window, cx: &mut Context<Self>) {