Skip to content

Commit c659928

Browse files
committed
request: Handle new RequestDevice and Ready requests
1 parent c8f43d7 commit c659928

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

src/request.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,22 @@ impl EisRequestConverter {
462462
self.queue_request(EisRequest::Bind(Bind { seat, capabilities }));
463463
return Ok(());
464464
}
465+
eis::seat::Request::RequestDevice { capabilities } => {
466+
let Some(seat) = self.connection.0.seats.lock().unwrap().get(seat).cloned() else {
467+
return Ok(());
468+
};
469+
470+
let capabilities = DeviceCapability::from_bits(*capabilities)
471+
.map_err(|_err| RequestError::InvalidCapabilities)?;
472+
if !seat.0.advertised_capabilities.contains(capabilities) {
473+
return Err(RequestError::InvalidCapabilities.into());
474+
}
475+
476+
self.queue_request(EisRequest::RequestDevice(RequestDevice {
477+
seat,
478+
capabilities,
479+
}));
480+
}
465481
}
466482
Ok(())
467483
}
@@ -507,6 +523,9 @@ impl EisRequestConverter {
507523
time: timestamp,
508524
}));
509525
}
526+
eis::device::Request::Ready => {
527+
self.queue_request(EisRequest::Ready(Ready { device }));
528+
}
510529
}
511530
}
512531

@@ -988,7 +1007,9 @@ pub enum EisRequest {
9881007
Disconnect,
9891008
Bind(Bind),
9901009
// Only for sender context
1010+
RequestDevice(RequestDevice),
9911011
Frame(Frame),
1012+
Ready(Ready),
9921013
DeviceStartEmulating(DeviceStartEmulating),
9931014
DeviceStopEmulating(DeviceStopEmulating),
9941015
PointerMotion(PointerMotion),
@@ -1025,7 +1046,9 @@ impl EisRequest {
10251046
Self::TouchCancel(evt) => Some(&mut evt.time),
10261047
Self::Disconnect
10271048
| Self::Bind(_)
1049+
| Self::RequestDevice(_)
10281050
| Self::Frame(_)
1051+
| Self::Ready(_)
10291052
| Self::DeviceStartEmulating(_)
10301053
| Self::DeviceStopEmulating(_) => None,
10311054
}
@@ -1036,6 +1059,7 @@ impl EisRequest {
10361059
pub fn device(&self) -> Option<&Device> {
10371060
match self {
10381061
Self::Frame(evt) => Some(&evt.device),
1062+
Self::Ready(evt) => Some(&evt.device),
10391063
Self::DeviceStartEmulating(evt) => Some(&evt.device),
10401064
Self::DeviceStopEmulating(evt) => Some(&evt.device),
10411065
Self::PointerMotion(evt) => Some(&evt.device),
@@ -1050,7 +1074,7 @@ impl EisRequest {
10501074
Self::TouchUp(evt) => Some(&evt.device),
10511075
Self::TouchMotion(evt) => Some(&evt.device),
10521076
Self::TouchCancel(evt) => Some(&evt.device),
1053-
Self::Disconnect | Self::Bind(_) => None,
1077+
Self::Disconnect | Self::Bind(_) | Self::RequestDevice(_) => None,
10541078
}
10551079
}
10561080
}
@@ -1064,6 +1088,15 @@ pub struct Bind {
10641088
pub capabilities: BitFlags<DeviceCapability>,
10651089
}
10661090

1091+
/// High-level translation of [`ei_seat.bind`](eis::seat::Request::RequestDevice).
1092+
#[derive(Clone, Debug, PartialEq)]
1093+
pub struct RequestDevice {
1094+
/// High-level [`Seat`] wrapper.
1095+
pub seat: Seat,
1096+
/// Capabilities requested by the client.
1097+
pub capabilities: BitFlags<DeviceCapability>,
1098+
}
1099+
10671100
/// High-level translation of [`ei_device.frame`](eis::device::Request::Frame).
10681101
#[derive(Clone, Debug, PartialEq)]
10691102
pub struct Frame {
@@ -1075,6 +1108,13 @@ pub struct Frame {
10751108
pub time: u64,
10761109
}
10771110

1111+
/// High-level translation of [`ei_device.ready`](eis::device::Request::Ready).
1112+
#[derive(Clone, Debug, PartialEq)]
1113+
pub struct Ready {
1114+
/// High-level [`Device`] wrapper.
1115+
pub device: Device,
1116+
}
1117+
10781118
/// High-level translation of [`ei_device.start_emulating`](eis::device::Request::StartEmulating).
10791119
#[derive(Clone, Debug, PartialEq)]
10801120
pub struct DeviceStartEmulating {

0 commit comments

Comments
 (0)