Skip to content

Commit

Permalink
Filter out per-pixel mouse movement when not in SGR-Pixels mode (#1549)
Browse files Browse the repository at this point in the history
* #1457 Initial commit compiles but doesn't yet work

* #1457 Fix cell offsets

* #1457 refactor, ClickPosition

* fix nits

* #1457 filter per-pixel motion when not in SGR-Pixels mode

* Much cleaner match condition for filtering mouse events based on encoding protocol
  • Loading branch information
Autumn Lamonte authored Jan 17, 2022
1 parent 11567c2 commit d3df292
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion term/src/terminalstate/mouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,18 @@ impl TerminalState {
}

fn mouse_move(&mut self, event: MouseEvent) -> anyhow::Result<()> {
let reportable = self.any_event_mouse || !self.current_mouse_buttons.is_empty();
let moved = match (&self.last_mouse_move, self.mouse_encoding) {
(None, _) => true,
(Some(last), MouseEncoding::SgrPixels) => {
last.x != event.x
|| last.y != event.y
|| last.x_pixel_offset != event.x_pixel_offset
|| last.y_pixel_offset != event.y_pixel_offset
}
(Some(last), _) => last.x != event.x || last.y != event.y,
};

let reportable = (self.any_event_mouse || !self.current_mouse_buttons.is_empty()) && moved;
// Note: self.mouse_tracking on its own is for clicks, not drags!
if reportable && (self.button_event_mouse || self.any_event_mouse) {
match self.last_mouse_move.as_ref() {
Expand Down

0 comments on commit d3df292

Please sign in to comment.