From a312e415951fcb9156572f124b42f68c09f60ae9 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 17 Apr 2021 19:28:23 +0000 Subject: Fix selection flooding Wayland connection This resolves an issue where an excessive clipboard update frequency would cause the Wayland display server to ignore necessary selection updates. Instead of copying the selection to the clipboard during the selection process, it is now only copied once the mouse button is released. Fixes #4953. --- alacritty/src/event.rs | 7 ++++--- alacritty/src/input.rs | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'alacritty/src') diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index e61354b8..612a0cc0 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -206,7 +206,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon // Update selection. if self.terminal.mode().contains(TermMode::VI) - && self.terminal.selection.as_ref().map(|s| s.is_empty()) != Some(true) + && self.terminal.selection.as_ref().map_or(true, |s| !s.is_empty()) { self.update_selection(self.terminal.vi_mode_cursor.point, Side::Right); } else if self.mouse.left_button_state == ElementState::Pressed @@ -216,6 +216,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon let point = self.mouse.point(&self.size_info(), display_offset); self.update_selection(point, self.mouse.cell_side); } + self.copy_selection(ClipboardType::Selection); *self.dirty = true; } @@ -262,8 +263,6 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon self.terminal.selection = Some(selection); *self.dirty = true; - - self.copy_selection(ClipboardType::Selection); } fn start_selection(&mut self, ty: SelectionType, point: Point, side: Side) { @@ -461,6 +460,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon let end = *focused_match.end(); self.start_selection(SelectionType::Simple, start, Side::Left); self.update_selection(end, Side::Right); + self.copy_selection(ClipboardType::Selection); } self.search_state.dfas = None; @@ -656,6 +656,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon HintAction::Action(HintInternalAction::Select) => { self.start_selection(SelectionType::Simple, *hint.bounds.start(), Side::Left); self.update_selection(*hint.bounds.end(), Side::Right); + self.copy_selection(ClipboardType::Selection); }, // Move the vi mode cursor. HintAction::Action(HintInternalAction::MoveViModeCursor) => { diff --git a/alacritty/src/input.rs b/alacritty/src/input.rs index 977a6e5d..3559b85e 100644 --- a/alacritty/src/input.rs +++ b/alacritty/src/input.rs @@ -634,6 +634,9 @@ impl> Processor { self.ctx.display().highlighted_hint = hint; self.ctx.scheduler_mut().unschedule(TimerId::SelectionScrolling); + + // Copy selection on release, to prevent flooding the display server. + self.ctx.copy_selection(ClipboardType::Selection); } pub fn mouse_wheel_input(&mut self, delta: MouseScrollDelta, phase: TouchPhase) { -- cgit