Add pointer button event passing
This commit is contained in:
parent
01884a6aa8
commit
2cc401594d
|
@ -1,7 +1,7 @@
|
|||
//! Implementation of input backend trait for types provided by `libinput`
|
||||
|
||||
use backend::SeatInternal;
|
||||
use backend::input::{InputBackend, InputHandler, Seat, SeatCapabilities};
|
||||
use backend::input::{InputBackend, InputHandler, Seat, SeatCapabilities, MouseButton};
|
||||
use input::{Libinput, Device, Seat as LibinputSeat, DeviceCapability};
|
||||
use input::event::*;
|
||||
|
||||
|
@ -214,7 +214,16 @@ impl InputBackend for LibinputInputBackend {
|
|||
}
|
||||
},
|
||||
PointerEvent::Button(button_event) => {
|
||||
|
||||
if let Some(ref mut handler) = self.handler {
|
||||
let device_seat = button_event.device().seat();
|
||||
let desc = self.seats.get_mut(&device_seat).expect("Recieved pointer event of non existing Seat");
|
||||
handler.on_pointer_button(&desc.seat, button_event.time(), match button_event.button() {
|
||||
0x110 => MouseButton::Left,
|
||||
0x111 => MouseButton::Right,
|
||||
0x112 => MouseButton::Middle,
|
||||
x => MouseButton::Other(x as u8),
|
||||
}, button_event.button_state().into());
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -244,3 +253,12 @@ impl From<::input::event::pointer::AxisSource> for ::backend::input::AxisSource
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::input::event::pointer::ButtonState> for ::backend::input::MouseButtonState {
|
||||
fn from(libinput: ::input::event::pointer::ButtonState) -> Self {
|
||||
match libinput {
|
||||
::input::event::pointer::ButtonState::Pressed => ::backend::input::MouseButtonState::Pressed,
|
||||
::input::event::pointer::ButtonState::Released => ::backend::input::MouseButtonState::Released,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue