Enable wheel down detection on ubuntu

This commit is contained in:
Alexandre Bury 2018-11-05 10:59:55 -08:00
parent 4f3299bf9f
commit 005d505cc4

View File

@ -123,8 +123,21 @@ impl InputParser {
if mevent.bstate == ncurses::REPORT_MOUSE_POSITION as mmask_t { if mevent.bstate == ncurses::REPORT_MOUSE_POSITION as mmask_t {
// The event is either a mouse drag event, // The event is either a mouse drag event,
// or a weird double-release event. :S // or a weird double-release event. :S
self.last_mouse_button self.last_mouse_button
.map(MouseEvent::Hold) .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) .map(&make_event)
.unwrap_or_else(|| Event::Unknown(vec![])) .unwrap_or_else(|| Event::Unknown(vec![]))
} else { } else {
@ -149,9 +162,15 @@ impl InputParser {
}); });
} }
if let Some(event) = event { if let Some(event) = event {
if let Some(btn) = event.button() { match event {
MouseEvent::Press(btn) => {
self.last_mouse_button = Some(btn); self.last_mouse_button = Some(btn);
} }
MouseEvent::Release(_) => {
self.last_mouse_button = None;
}
_ => (),
}
make_event(event) make_event(event)
} else { } else {
debug!("No event parsed?..."); debug!("No event parsed?...");