From 005d505cc4a9cf07de1d15d51cc1cc72dbb49f73 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 5 Nov 2018 10:59:55 -0800 Subject: [PATCH] Enable wheel down detection on ubuntu --- src/backend/curses/n.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/backend/curses/n.rs b/src/backend/curses/n.rs index e76e2ed..abb4042 100644 --- a/src/backend/curses/n.rs +++ b/src/backend/curses/n.rs @@ -123,8 +123,21 @@ impl InputParser { if mevent.bstate == ncurses::REPORT_MOUSE_POSITION as mmask_t { // The event is either a mouse drag event, // or a weird double-release event. :S + self.last_mouse_button .map(MouseEvent::Hold) + .or_else(|| { + // In legacy mode, some buttons overlap, + // so we need to disambiguate. + if mevent.bstate + == ncurses::BUTTON5_DOUBLE_CLICKED as mmask_t + { + Some(MouseEvent::WheelDown) + } else { + // None + Some(MouseEvent::WheelDown) + } + }) .map(&make_event) .unwrap_or_else(|| Event::Unknown(vec![])) } else { @@ -149,8 +162,14 @@ impl InputParser { }); } if let Some(event) = event { - if let Some(btn) = event.button() { - self.last_mouse_button = Some(btn); + match event { + MouseEvent::Press(btn) => { + self.last_mouse_button = Some(btn); + } + MouseEvent::Release(_) => { + self.last_mouse_button = None; + } + _ => (), } make_event(event) } else {