From 64a3115648d354731ef08c2de8b2168b9326b7b5 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 7 Mar 2020 22:17:38 +0000 Subject: Fix selection with invisible start and end This resolves an issue with the selection clamping, where no selection would be rendered at all when the start was above the viewport while the end was below it. --- alacritty/src/event.rs | 75 ++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 39 deletions(-) (limited to 'alacritty/src') diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 5888140f..94a340d7 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -11,7 +11,9 @@ use std::sync::Arc; use std::time::Instant; use glutin::dpi::PhysicalSize; -use glutin::event::{ElementState, Event as GlutinEvent, ModifiersState, MouseButton, WindowEvent}; +use glutin::event::{ + DeviceEvent, ElementState, Event as GlutinEvent, ModifiersState, MouseButton, WindowEvent, +}; use glutin::event_loop::{ControlFlow, EventLoop, EventLoopProxy, EventLoopWindowTarget}; use glutin::platform::desktop::EventLoopExtDesktop; use log::{debug, info, warn}; @@ -519,10 +521,9 @@ impl Processor { }, GlutinEvent::RedrawRequested(_) => processor.ctx.terminal.dirty = true, GlutinEvent::WindowEvent { event, window_id, .. } => { - use glutin::event::WindowEvent::*; match event { - CloseRequested => processor.ctx.terminal.exit(), - Resized(size) => { + WindowEvent::CloseRequested => processor.ctx.terminal.exit(), + WindowEvent::Resized(size) => { #[cfg(windows)] { // Minimizing the window sends a Resize event with zero width and @@ -537,7 +538,7 @@ impl Processor { processor.ctx.display_update_pending.dimensions = Some(size); processor.ctx.terminal.dirty = true; }, - KeyboardInput { input, is_synthetic: false, .. } => { + WindowEvent::KeyboardInput { input, is_synthetic: false, .. } => { processor.key_input(input); if input.state == ElementState::Pressed { // Hide cursor while typing @@ -546,13 +547,13 @@ impl Processor { } } }, - ReceivedCharacter(c) => processor.received_char(c), - MouseInput { state, button, .. } => { + WindowEvent::ReceivedCharacter(c) => processor.received_char(c), + WindowEvent::MouseInput { state, button, .. } => { processor.ctx.window.set_mouse_visible(true); processor.mouse_input(state, button); processor.ctx.terminal.dirty = true; }, - CursorMoved { position, .. } => { + WindowEvent::CursorMoved { position, .. } => { let (x, y) = position.into(); let x = limit(x, 0, processor.ctx.size_info.width as i32); let y = limit(y, 0, processor.ctx.size_info.height as i32); @@ -560,11 +561,11 @@ impl Processor { processor.ctx.window.set_mouse_visible(true); processor.mouse_moved(x as usize, y as usize); }, - MouseWheel { delta, phase, .. } => { + WindowEvent::MouseWheel { delta, phase, .. } => { processor.ctx.window.set_mouse_visible(true); processor.mouse_wheel_input(delta, phase); }, - Focused(is_focused) => { + WindowEvent::Focused(is_focused) => { if window_id == processor.ctx.window.window_id() { processor.ctx.terminal.is_focused = is_focused; processor.ctx.terminal.dirty = true; @@ -578,33 +579,32 @@ impl Processor { processor.on_focus_change(is_focused); } }, - DroppedFile(path) => { + WindowEvent::DroppedFile(path) => { let path: String = path.to_string_lossy().into(); processor.ctx.write_to_pty(path.into_bytes()); }, - CursorLeft { .. } => { + WindowEvent::CursorLeft { .. } => { processor.ctx.mouse.inside_grid = false; if processor.highlighted_url.is_some() { processor.ctx.terminal.dirty = true; } }, - KeyboardInput { is_synthetic: true, .. } - | TouchpadPressure { .. } - | ScaleFactorChanged { .. } - | CursorEntered { .. } - | AxisMotion { .. } - | HoveredFileCancelled - | Destroyed - | ThemeChanged(_) - | HoveredFile(_) - | Touch(_) - | Moved(_) => (), + WindowEvent::KeyboardInput { is_synthetic: true, .. } + | WindowEvent::TouchpadPressure { .. } + | WindowEvent::ScaleFactorChanged { .. } + | WindowEvent::CursorEntered { .. } + | WindowEvent::AxisMotion { .. } + | WindowEvent::HoveredFileCancelled + | WindowEvent::Destroyed + | WindowEvent::ThemeChanged(_) + | WindowEvent::HoveredFile(_) + | WindowEvent::Touch(_) + | WindowEvent::Moved(_) => (), } }, GlutinEvent::DeviceEvent { event, .. } => { - use glutin::event::DeviceEvent::*; - if let ModifiersChanged(modifiers) = event { + if let DeviceEvent::ModifiersChanged(modifiers) = event { processor.modifiers_input(modifiers); } }, @@ -620,20 +620,17 @@ impl Processor { /// Check if an event is irrelevant and can be skipped fn skip_event(event: &GlutinEvent) -> bool { match event { - GlutinEvent::WindowEvent { event, .. } => { - use glutin::event::WindowEvent::*; - match event { - KeyboardInput { is_synthetic: true, .. } - | TouchpadPressure { .. } - | CursorEntered { .. } - | AxisMotion { .. } - | HoveredFileCancelled - | Destroyed - | HoveredFile(_) - | Touch(_) - | Moved(_) => true, - _ => false, - } + GlutinEvent::WindowEvent { event, .. } => match event { + WindowEvent::KeyboardInput { is_synthetic: true, .. } + | WindowEvent::TouchpadPressure { .. } + | WindowEvent::CursorEntered { .. } + | WindowEvent::AxisMotion { .. } + | WindowEvent::HoveredFileCancelled + | WindowEvent::Destroyed + | WindowEvent::HoveredFile(_) + | WindowEvent::Touch(_) + | WindowEvent::Moved(_) => true, + _ => false, }, GlutinEvent::Suspended { .. } | GlutinEvent::NewEvents { .. } -- cgit