1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-25 14:22:37 +03:00

filter mouse buttons

This commit is contained in:
Gus Wynn 2021-04-01 07:57:05 -07:00 committed by Wez Furlong
parent 0bae61d580
commit e84811085e

View File

@ -1497,8 +1497,17 @@ impl WindowView {
} }
extern "C" fn other_mouse_up(this: &mut Object, _sel: Sel, nsevent: id) { extern "C" fn other_mouse_up(this: &mut Object, _sel: Sel, nsevent: id) {
// Safety: We know this is an button event
unsafe {
let button_number = NSEvent::buttonNumber(nsevent);
// Button 2 is the middle mouse button (scroll wheel)
// At least on the tested mouse, the dedicated middle mouse button
// is button 4. This should probably be made configurable at some point
if [2, 4].contains(&button_number) {
Self::mouse_common(this, nsevent, MouseEventKind::Release(MousePress::Middle)); Self::mouse_common(this, nsevent, MouseEventKind::Release(MousePress::Middle));
} }
}
}
extern "C" fn scroll_wheel(this: &mut Object, _sel: Sel, nsevent: id) { extern "C" fn scroll_wheel(this: &mut Object, _sel: Sel, nsevent: id) {
let precise = unsafe { nsevent.hasPreciseScrollingDeltas() } == YES; let precise = unsafe { nsevent.hasPreciseScrollingDeltas() } == YES;