mirror of
https://github.com/alacritty/alacritty.git
synced 2025-02-10 15:46:10 -05:00
Fix double-triggering of mouse bindings
The2d9afb9b39
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 in2d9afb9b39
. 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.
This commit is contained in:
parent
2d9afb9b39
commit
f4fc9eb35a
1 changed files with 11 additions and 19 deletions
30
src/input.rs
30
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),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue