wayland: implement wl_touch
Co-authored-by: Julian Orth <ju.orth@gmail.com>
This commit is contained in:
parent
905e2dd7ba
commit
681c1ad033
35 changed files with 1071 additions and 52 deletions
|
|
@ -376,6 +376,7 @@ struct InputDeviceProperties {
|
|||
drag_enabled: Cell<Option<bool>>,
|
||||
drag_lock_enabled: Cell<Option<bool>>,
|
||||
natural_scrolling_enabled: Cell<Option<bool>>,
|
||||
calibration_matrix: Cell<Option<[[f32; 3]; 2]>>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
@ -436,6 +437,9 @@ impl MetalInputDevice {
|
|||
if let Some(enabled) = self.desired.natural_scrolling_enabled.get() {
|
||||
self.set_natural_scrolling_enabled(enabled);
|
||||
}
|
||||
if let Some(lh) = self.desired.calibration_matrix.get() {
|
||||
self.set_calibration_matrix(lh);
|
||||
}
|
||||
self.fetch_effective();
|
||||
}
|
||||
|
||||
|
|
@ -465,6 +469,11 @@ impl MetalInputDevice {
|
|||
.natural_scrolling_enabled
|
||||
.set(Some(device.natural_scrolling_enabled()));
|
||||
}
|
||||
if device.has_calibration_matrix() {
|
||||
self.effective
|
||||
.calibration_matrix
|
||||
.set(Some(device.get_calibration_matrix()));
|
||||
}
|
||||
}
|
||||
|
||||
fn pre_pause(&self) {
|
||||
|
|
@ -721,6 +730,22 @@ impl InputDevice for MetalInputDevice {
|
|||
groups,
|
||||
}))
|
||||
}
|
||||
|
||||
fn calibration_matrix(&self) -> Option<[[f32; 3]; 2]> {
|
||||
self.effective.calibration_matrix.get()
|
||||
}
|
||||
|
||||
fn set_calibration_matrix(&self, m: [[f32; 3]; 2]) {
|
||||
self.desired.calibration_matrix.set(Some(m));
|
||||
if let Some(dev) = self.inputdev.get() {
|
||||
if dev.device().has_calibration_matrix() {
|
||||
dev.device().set_calibration_matrix(m);
|
||||
self.effective
|
||||
.calibration_matrix
|
||||
.set(Some(dev.device().get_calibration_matrix()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MetalInputDevice {
|
||||
|
|
|
|||
|
|
@ -121,6 +121,11 @@ impl MetalBackend {
|
|||
c::LIBINPUT_EVENT_TABLET_PAD_BUTTON => self.handle_tablet_pad_button(event),
|
||||
c::LIBINPUT_EVENT_TABLET_PAD_RING => self.handle_tablet_pad_ring(event),
|
||||
c::LIBINPUT_EVENT_TABLET_PAD_STRIP => self.handle_tablet_pad_strip(event),
|
||||
c::LIBINPUT_EVENT_TOUCH_DOWN => self.handle_touch_down(event),
|
||||
c::LIBINPUT_EVENT_TOUCH_UP => self.handle_touch_up(event),
|
||||
c::LIBINPUT_EVENT_TOUCH_MOTION => self.handle_touch_motion(event),
|
||||
c::LIBINPUT_EVENT_TOUCH_CANCEL => self.handle_touch_cancel(event),
|
||||
c::LIBINPUT_EVENT_TOUCH_FRAME => self.handle_touch_frame(event),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -539,4 +544,45 @@ impl MetalBackend {
|
|||
},
|
||||
});
|
||||
}
|
||||
|
||||
fn handle_touch_down(self: &Rc<Self>, event: LibInputEvent) {
|
||||
let (event, dev) = unpack!(self, event, touch_event);
|
||||
dev.event(InputEvent::TouchDown {
|
||||
time_usec: event.time_usec(),
|
||||
id: event.seat_slot(),
|
||||
x_normed: Fixed::from_f64(event.x_transformed(1)),
|
||||
y_normed: Fixed::from_f64(event.y_transformed(1)),
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_touch_up(self: &Rc<Self>, event: LibInputEvent) {
|
||||
let (event, dev) = unpack!(self, event, touch_event);
|
||||
dev.event(InputEvent::TouchUp {
|
||||
time_usec: event.time_usec(),
|
||||
id: event.seat_slot(),
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_touch_motion(self: &Rc<Self>, event: LibInputEvent) {
|
||||
let (event, dev) = unpack!(self, event, touch_event);
|
||||
dev.event(InputEvent::TouchMotion {
|
||||
time_usec: event.time_usec(),
|
||||
id: event.seat_slot(),
|
||||
x_normed: Fixed::from_f64(event.x_transformed(1)),
|
||||
y_normed: Fixed::from_f64(event.y_transformed(1)),
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_touch_cancel(self: &Rc<Self>, event: LibInputEvent) {
|
||||
let (event, dev) = unpack!(self, event, touch_event);
|
||||
dev.event(InputEvent::TouchCancel {
|
||||
time_usec: event.time_usec(),
|
||||
id: event.seat_slot(),
|
||||
})
|
||||
}
|
||||
|
||||
fn handle_touch_frame(self: &Rc<Self>, event: LibInputEvent) {
|
||||
let (_, dev) = unpack!(self, event, touch_event);
|
||||
dev.event(InputEvent::TouchFrame)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue