Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve dirty detection when scrolling and typing characters #6206

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions alacritty/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
}

fn clear_selection(&mut self) {
self.terminal.selection = None;
*self.dirty = true;
let old_selection = self.terminal.selection.take();
*self.dirty |= old_selection.map(|s| !s.is_empty()).unwrap_or(false);
}

fn update_selection(&mut self, mut point: Point, side: Side) {
Expand Down Expand Up @@ -651,13 +651,14 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
let timer_id = TimerId::new(Topic::BlinkCursor, self.display.window.id());
if self.scheduler.unschedule(timer_id).is_some() {
self.schedule_blinking();
self.display.cursor_hidden = false;
if self.display.cursor_hidden {
self.display.cursor_hidden = false;
*self.dirty = true;
}
} else if *self.cursor_blink_timed_out {
self.update_cursor_blinking();
}

*self.dirty = true;

// Hide mouse cursor.
if self.config.mouse.hide_when_typing {
self.display.window.set_mouse_visible(false);
Expand Down
11 changes: 9 additions & 2 deletions alacritty/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,12 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
let multiplier = f64::from(self.ctx.config().terminal_config.scrolling.multiplier);
self.ctx.mouse_mut().scroll_px += new_scroll_px * multiplier;

let lines = self.ctx.mouse().scroll_px / height;
let lines = (self.ctx.mouse().scroll_px / height) as i32;

self.ctx.scroll(Scroll::Delta(lines as i32));
// Scroll only if we've actually scrolled.
if lines != 0 {
self.ctx.scroll(Scroll::Delta(lines));
}
}

self.ctx.mouse_mut().scroll_px %= height;
Expand Down Expand Up @@ -815,6 +818,10 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
return;
}

// XXX when we're writing keyboard input to pty we must not mark the terminal as dirty
// unless there's a need for visual update, like clearing a selection. Or scrolling to
// the viewport to bottom.

self.ctx.on_typing_start();

if self.ctx.terminal().grid().display_offset() != 0 {
Expand Down