alacritty

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit f4fc9eb35a02426dac33a19e2cb9ff182d745316
parent 2d9afb9b395ea0cc71432613e0df104aefcf24c1
Author: Christian Duerr <chrisduerr@users.noreply.github.com>
Date:   Thu,  3 Jan 2019 01:56:28 +0000

Fix double-triggering of mouse bindings

The 2d9afb9b395ea0cc71432613e0df104aefcf24c1 commit lead to mouse
actions being triggered on both press and release of mouse buttons.

This reverts the mouse binding behavior back to the previous state where
they are only triggered when the button is pressed, not when it's
released.

The `mouse_input` method's structure was overly complicated and did not
accurately represent the logic which should be implemented by it. This
is likely what caused the regression in 2d9afb9b395ea0cc71432613e0df104aefcf24c1.

To prevent similar issues from popping up in the future, the method has
been cleaned up and the structure should now represent the logic
required more logically.

Diffstat:
Msrc/input.rs | 30+++++++++++-------------------
1 file changed, 11 insertions(+), 19 deletions(-)

diff --git a/src/input.rs b/src/input.rs @@ -638,27 +638,19 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { } pub fn mouse_input(&mut self, state: ElementState, button: MouseButton, modifiers: ModifiersState) { - let prev_state = match button { - MouseButton::Left => Some(mem::replace(&mut self.ctx.mouse_mut().left_button_state, state)), - MouseButton::Middle => Some(mem::replace(&mut self.ctx.mouse_mut().middle_button_state, state)), - MouseButton::Right => Some(mem::replace(&mut self.ctx.mouse_mut().right_button_state, state)), - // Can't properly report more than three buttons. - MouseButton::Other(_) => None, - }; - - self.process_mouse_bindings(modifiers, button); - - if let Some(prev_state) = prev_state { - if prev_state != state { - match state { - ElementState::Pressed => self.on_mouse_press(button, modifiers), - ElementState::Released => self.on_mouse_release(button, modifiers), - }; - } + match button { + MouseButton::Left => self.ctx.mouse_mut().left_button_state = state, + MouseButton::Middle => self.ctx.mouse_mut().middle_button_state = state, + MouseButton::Right => self.ctx.mouse_mut().right_button_state = state, + _ => (), } - if let ElementState::Released = state { - return; + match state { + ElementState::Pressed => { + self.process_mouse_bindings(modifiers, button); + self.on_mouse_press(button, modifiers); + }, + ElementState::Released => self.on_mouse_release(button, modifiers), } }