#![allow(
unused_parens,
clippy::useless_conversion,
clippy::double_parens,
clippy::match_single_binding
)]
pub mod handshake {
#[derive(Clone, Debug)]
pub struct Handshake(pub(crate) crate::Object);
impl crate::private::Sealed for Handshake {}
impl crate::Interface for Handshake {
const NAME: &'static str = "ei_handshake";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Handshake {}
impl Handshake {
pub fn handshake_version(&self, version: u32) -> () {
let args = &[crate::Arg::Uint32(version.into())];
self.0.request(0, args);
()
}
pub fn interface_version(&self, name: &str, version: u32) -> () {
let args = &[
crate::Arg::String(name.into()),
crate::Arg::Uint32(version.into()),
];
self.0.request(1, args);
()
}
pub fn connection(&self, serial: u32, version: u32) -> (super::connection::Connection) {
let connection = self
.0
.backend()
.new_id("ei_connection".to_string(), version);
let args = &[
crate::Arg::Uint32(serial.into()),
crate::Arg::NewId(connection.into()),
crate::Arg::Uint32(version.into()),
];
self.0.request(2, args);
self.0.backend().remove_id(self.0.id());
(super::connection::Connection(crate::Object::new(
self.0.backend().clone(),
connection,
false,
)))
}
}
#[derive(Clone, Copy, Debug)]
pub enum ContextType {
Receiver = 1,
Sender = 2,
}
impl From<ContextType> for u32 {
fn from(value: ContextType) -> u32 {
value as u32
}
}
impl crate::OwnedArg for ContextType {
fn parse(buf: &mut crate::ByteStream) -> Result<Self, crate::ParseError> {
match u32::parse(buf)? {
1 => Ok(Self::Receiver),
2 => Ok(Self::Sender),
variant => Err(crate::ParseError::InvalidVariant("ContextType", variant)),
}
}
fn as_arg(&self) -> crate::Arg<'_> {
crate::Arg::Uint32(*self as u32)
}
fn enum_name(&self) -> Option<(&'static str, &'static str)> {
Some((
"context_type",
match self {
Self::Receiver => "receiver",
Self::Sender => "sender",
},
))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
HandshakeVersion {
version: u32,
},
Finish,
ContextType {
context_type: ContextType,
},
Name {
name: String,
},
InterfaceVersion {
name: String,
version: u32,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("handshake_version"),
1 => Some("finish"),
2 => Some("context_type"),
3 => Some("name"),
4 => Some("interface_version"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => {
let version = _bytes.read_arg()?;
Ok(Self::HandshakeVersion { version })
}
1 => Ok(Self::Finish),
2 => {
let context_type = _bytes.read_arg()?;
Ok(Self::ContextType { context_type })
}
3 => {
let name = _bytes.read_arg()?;
Ok(Self::Name { name })
}
4 => {
let name = _bytes.read_arg()?;
let version = _bytes.read_arg()?;
Ok(Self::InterfaceVersion { name, version })
}
opcode => Err(crate::ParseError::InvalidOpcode("handshake", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::HandshakeVersion { version } => {
args.push(version.as_arg());
}
Self::Finish => {}
Self::ContextType { context_type } => {
args.push(context_type.as_arg());
}
Self::Name { name } => {
args.push(name.as_arg());
}
Self::InterfaceVersion { name, version } => {
args.push(name.as_arg());
args.push(version.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use handshake::Handshake;
pub mod connection {
#[derive(Clone, Debug)]
pub struct Connection(pub(crate) crate::Object);
impl crate::private::Sealed for Connection {}
impl crate::Interface for Connection {
const NAME: &'static str = "ei_connection";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Connection {}
impl Connection {
pub fn disconnected(
&self,
last_serial: u32,
reason: DisconnectReason,
explanation: &str,
) -> () {
let args = &[
crate::Arg::Uint32(last_serial.into()),
crate::Arg::Uint32(reason.into()),
crate::Arg::String(explanation.into()),
];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn seat(&self, version: u32) -> (super::seat::Seat) {
let seat = self.0.backend().new_id("ei_seat".to_string(), version);
let args = &[
crate::Arg::NewId(seat.into()),
crate::Arg::Uint32(version.into()),
];
self.0.request(1, args);
(super::seat::Seat(crate::Object::new(self.0.backend().clone(), seat, false)))
}
pub fn invalid_object(&self, last_serial: u32, invalid_id: u64) -> () {
let args = &[
crate::Arg::Uint32(last_serial.into()),
crate::Arg::Uint64(invalid_id.into()),
];
self.0.request(2, args);
()
}
pub fn ping(&self, version: u32) -> (super::pingpong::Pingpong) {
let ping = self.0.backend().new_id("ei_pingpong".to_string(), version);
let args = &[
crate::Arg::NewId(ping.into()),
crate::Arg::Uint32(version.into()),
];
self.0.request(3, args);
(super::pingpong::Pingpong(crate::Object::new(self.0.backend().clone(), ping, false)))
}
}
#[derive(Clone, Copy, Debug)]
pub enum DisconnectReason {
Disconnected = 0,
Error = 1,
Mode = 2,
Protocol = 3,
Value = 4,
Transport = 5,
}
impl From<DisconnectReason> for u32 {
fn from(value: DisconnectReason) -> u32 {
value as u32
}
}
impl crate::OwnedArg for DisconnectReason {
fn parse(buf: &mut crate::ByteStream) -> Result<Self, crate::ParseError> {
match u32::parse(buf)? {
0 => Ok(Self::Disconnected),
1 => Ok(Self::Error),
2 => Ok(Self::Mode),
3 => Ok(Self::Protocol),
4 => Ok(Self::Value),
5 => Ok(Self::Transport),
variant => Err(crate::ParseError::InvalidVariant(
"DisconnectReason",
variant,
)),
}
}
fn as_arg(&self) -> crate::Arg<'_> {
crate::Arg::Uint32(*self as u32)
}
fn enum_name(&self) -> Option<(&'static str, &'static str)> {
Some((
"disconnect_reason",
match self {
Self::Disconnected => "disconnected",
Self::Error => "error",
Self::Mode => "mode",
Self::Protocol => "protocol",
Self::Value => "value",
Self::Transport => "transport",
},
))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Sync {
callback: super::callback::Callback,
},
Disconnect,
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("sync"),
1 => Some("disconnect"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => {
let callback = _bytes.read_arg()?;
let version = _bytes.read_arg()?;
Ok(Self::Sync {
callback: _bytes.backend().new_peer_interface(callback, version)?,
})
}
1 => Ok(Self::Disconnect),
opcode => Err(crate::ParseError::InvalidOpcode("connection", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Sync { callback } => {
args.push(callback.as_arg());
}
Self::Disconnect => {}
_ => unreachable!(),
}
args
}
}
}
pub use connection::Connection;
pub mod callback {
#[derive(Clone, Debug)]
pub struct Callback(pub(crate) crate::Object);
impl crate::private::Sealed for Callback {}
impl crate::Interface for Callback {
const NAME: &'static str = "ei_callback";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Callback {}
impl Callback {
pub fn done(&self, callback_data: u64) -> () {
let args = &[crate::Arg::Uint64(callback_data.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
opcode => Err(crate::ParseError::InvalidOpcode("callback", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
_ => unreachable!(),
}
args
}
}
}
pub use callback::Callback;
pub mod pingpong {
#[derive(Clone, Debug)]
pub struct Pingpong(pub(crate) crate::Object);
impl crate::private::Sealed for Pingpong {}
impl crate::Interface for Pingpong {
const NAME: &'static str = "ei_pingpong";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Pingpong {}
impl Pingpong {}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Done {
callback_data: u64,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("done"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => {
let callback_data = _bytes.read_arg()?;
Ok(Self::Done { callback_data })
}
opcode => Err(crate::ParseError::InvalidOpcode("pingpong", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Done { callback_data } => {
args.push(callback_data.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use pingpong::Pingpong;
pub mod seat {
#[derive(Clone, Debug)]
pub struct Seat(pub(crate) crate::Object);
impl crate::private::Sealed for Seat {}
impl crate::Interface for Seat {
const NAME: &'static str = "ei_seat";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Seat {}
impl Seat {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn name(&self, name: &str) -> () {
let args = &[crate::Arg::String(name.into())];
self.0.request(1, args);
()
}
pub fn capability(&self, mask: u64, interface: &str) -> () {
let args = &[
crate::Arg::Uint64(mask.into()),
crate::Arg::String(interface.into()),
];
self.0.request(2, args);
()
}
pub fn done(&self) -> () {
let args = &[];
self.0.request(3, args);
()
}
pub fn device(&self, version: u32) -> (super::device::Device) {
let device = self.0.backend().new_id("ei_device".to_string(), version);
let args = &[
crate::Arg::NewId(device.into()),
crate::Arg::Uint32(version.into()),
];
self.0.request(4, args);
(super::device::Device(crate::Object::new(self.0.backend().clone(), device, false)))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
Bind {
capabilities: u64,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("bind"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let capabilities = _bytes.read_arg()?;
Ok(Self::Bind { capabilities })
}
opcode => Err(crate::ParseError::InvalidOpcode("seat", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::Bind { capabilities } => {
args.push(capabilities.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use seat::Seat;
pub mod device {
#[derive(Clone, Debug)]
pub struct Device(pub(crate) crate::Object);
impl crate::private::Sealed for Device {}
impl crate::Interface for Device {
const NAME: &'static str = "ei_device";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Device {}
impl Device {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn name(&self, name: &str) -> () {
let args = &[crate::Arg::String(name.into())];
self.0.request(1, args);
()
}
pub fn device_type(&self, device_type: DeviceType) -> () {
let args = &[crate::Arg::Uint32(device_type.into())];
self.0.request(2, args);
()
}
pub fn dimensions(&self, width: u32, height: u32) -> () {
let args = &[
crate::Arg::Uint32(width.into()),
crate::Arg::Uint32(height.into()),
];
self.0.request(3, args);
()
}
pub fn region(
&self,
offset_x: u32,
offset_y: u32,
width: u32,
hight: u32,
scale: f32,
) -> () {
let args = &[
crate::Arg::Uint32(offset_x.into()),
crate::Arg::Uint32(offset_y.into()),
crate::Arg::Uint32(width.into()),
crate::Arg::Uint32(hight.into()),
crate::Arg::Float(scale.into()),
];
self.0.request(4, args);
()
}
pub fn interface<InterfaceName: crate::eis::Interface>(
&self,
version: u32,
) -> (InterfaceName) {
let object = self
.0
.backend()
.new_id(InterfaceName::NAME.to_string(), version);
let args = &[
crate::Arg::NewId(object.into()),
crate::Arg::String(InterfaceName::NAME),
crate::Arg::Uint32(version.into()),
];
self.0.request(5, args);
(crate::Object::new(self.0.backend().clone(), object, false).downcast_unchecked())
}
pub fn done(&self) -> () {
let args = &[];
self.0.request(6, args);
()
}
pub fn resumed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(7, args);
()
}
pub fn paused(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(8, args);
()
}
pub fn start_emulating(&self, serial: u32, sequence: u32) -> () {
let args = &[
crate::Arg::Uint32(serial.into()),
crate::Arg::Uint32(sequence.into()),
];
self.0.request(9, args);
()
}
pub fn stop_emulating(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(10, args);
()
}
pub fn frame(&self, serial: u32, timestamp: u64) -> () {
let args = &[
crate::Arg::Uint32(serial.into()),
crate::Arg::Uint64(timestamp.into()),
];
self.0.request(11, args);
()
}
}
#[derive(Clone, Copy, Debug)]
pub enum DeviceType {
Virtual = 1,
Physical = 2,
}
impl From<DeviceType> for u32 {
fn from(value: DeviceType) -> u32 {
value as u32
}
}
impl crate::OwnedArg for DeviceType {
fn parse(buf: &mut crate::ByteStream) -> Result<Self, crate::ParseError> {
match u32::parse(buf)? {
1 => Ok(Self::Virtual),
2 => Ok(Self::Physical),
variant => Err(crate::ParseError::InvalidVariant("DeviceType", variant)),
}
}
fn as_arg(&self) -> crate::Arg<'_> {
crate::Arg::Uint32(*self as u32)
}
fn enum_name(&self) -> Option<(&'static str, &'static str)> {
Some((
"device_type",
match self {
Self::Virtual => "virtual",
Self::Physical => "physical",
},
))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
StartEmulating {
last_serial: u32,
sequence: u32,
},
StopEmulating {
last_serial: u32,
},
Frame {
last_serial: u32,
timestamp: u64,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("start_emulating"),
2 => Some("stop_emulating"),
3 => Some("frame"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let last_serial = _bytes.read_arg()?;
let sequence = _bytes.read_arg()?;
Ok(Self::StartEmulating {
last_serial,
sequence,
})
}
2 => {
let last_serial = _bytes.read_arg()?;
Ok(Self::StopEmulating { last_serial })
}
3 => {
let last_serial = _bytes.read_arg()?;
let timestamp = _bytes.read_arg()?;
Ok(Self::Frame {
last_serial,
timestamp,
})
}
opcode => Err(crate::ParseError::InvalidOpcode("device", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::StartEmulating {
last_serial,
sequence,
} => {
args.push(last_serial.as_arg());
args.push(sequence.as_arg());
}
Self::StopEmulating { last_serial } => {
args.push(last_serial.as_arg());
}
Self::Frame {
last_serial,
timestamp,
} => {
args.push(last_serial.as_arg());
args.push(timestamp.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use device::Device;
pub mod pointer {
#[derive(Clone, Debug)]
pub struct Pointer(pub(crate) crate::Object);
impl crate::private::Sealed for Pointer {}
impl crate::Interface for Pointer {
const NAME: &'static str = "ei_pointer";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Pointer {}
impl Pointer {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn motion_relative(&self, x: f32, y: f32) -> () {
let args = &[crate::Arg::Float(x.into()), crate::Arg::Float(y.into())];
self.0.request(1, args);
()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
MotionRelative {
x: f32,
y: f32,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("motion_relative"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let x = _bytes.read_arg()?;
let y = _bytes.read_arg()?;
Ok(Self::MotionRelative { x, y })
}
opcode => Err(crate::ParseError::InvalidOpcode("pointer", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::MotionRelative { x, y } => {
args.push(x.as_arg());
args.push(y.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use pointer::Pointer;
pub mod pointer_absolute {
#[derive(Clone, Debug)]
pub struct PointerAbsolute(pub(crate) crate::Object);
impl crate::private::Sealed for PointerAbsolute {}
impl crate::Interface for PointerAbsolute {
const NAME: &'static str = "ei_pointer_absolute";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for PointerAbsolute {}
impl PointerAbsolute {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn motion_absolute(&self, x: f32, y: f32) -> () {
let args = &[crate::Arg::Float(x.into()), crate::Arg::Float(y.into())];
self.0.request(1, args);
()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
MotionAbsolute {
x: f32,
y: f32,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("motion_absolute"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let x = _bytes.read_arg()?;
let y = _bytes.read_arg()?;
Ok(Self::MotionAbsolute { x, y })
}
opcode => Err(crate::ParseError::InvalidOpcode("pointer_absolute", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::MotionAbsolute { x, y } => {
args.push(x.as_arg());
args.push(y.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use pointer_absolute::PointerAbsolute;
pub mod scroll {
#[derive(Clone, Debug)]
pub struct Scroll(pub(crate) crate::Object);
impl crate::private::Sealed for Scroll {}
impl crate::Interface for Scroll {
const NAME: &'static str = "ei_scroll";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Scroll {}
impl Scroll {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn scroll(&self, x: f32, y: f32) -> () {
let args = &[crate::Arg::Float(x.into()), crate::Arg::Float(y.into())];
self.0.request(1, args);
()
}
pub fn scroll_discrete(&self, x: i32, y: i32) -> () {
let args = &[crate::Arg::Int32(x.into()), crate::Arg::Int32(y.into())];
self.0.request(2, args);
()
}
pub fn scroll_stop(&self, x: u32, y: u32, is_cancel: u32) -> () {
let args = &[
crate::Arg::Uint32(x.into()),
crate::Arg::Uint32(y.into()),
crate::Arg::Uint32(is_cancel.into()),
];
self.0.request(3, args);
()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
Scroll {
x: f32,
y: f32,
},
ScrollDiscrete {
x: i32,
y: i32,
},
ScrollStop {
x: u32,
y: u32,
is_cancel: u32,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("scroll"),
2 => Some("scroll_discrete"),
3 => Some("scroll_stop"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let x = _bytes.read_arg()?;
let y = _bytes.read_arg()?;
Ok(Self::Scroll { x, y })
}
2 => {
let x = _bytes.read_arg()?;
let y = _bytes.read_arg()?;
Ok(Self::ScrollDiscrete { x, y })
}
3 => {
let x = _bytes.read_arg()?;
let y = _bytes.read_arg()?;
let is_cancel = _bytes.read_arg()?;
Ok(Self::ScrollStop { x, y, is_cancel })
}
opcode => Err(crate::ParseError::InvalidOpcode("scroll", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::Scroll { x, y } => {
args.push(x.as_arg());
args.push(y.as_arg());
}
Self::ScrollDiscrete { x, y } => {
args.push(x.as_arg());
args.push(y.as_arg());
}
Self::ScrollStop { x, y, is_cancel } => {
args.push(x.as_arg());
args.push(y.as_arg());
args.push(is_cancel.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use scroll::Scroll;
pub mod button {
#[derive(Clone, Debug)]
pub struct Button(pub(crate) crate::Object);
impl crate::private::Sealed for Button {}
impl crate::Interface for Button {
const NAME: &'static str = "ei_button";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Button {}
impl Button {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn button(&self, button: u32, state: ButtonState) -> () {
let args = &[
crate::Arg::Uint32(button.into()),
crate::Arg::Uint32(state.into()),
];
self.0.request(1, args);
()
}
}
#[derive(Clone, Copy, Debug)]
pub enum ButtonState {
Released = 0,
Press = 1,
}
impl From<ButtonState> for u32 {
fn from(value: ButtonState) -> u32 {
value as u32
}
}
impl crate::OwnedArg for ButtonState {
fn parse(buf: &mut crate::ByteStream) -> Result<Self, crate::ParseError> {
match u32::parse(buf)? {
0 => Ok(Self::Released),
1 => Ok(Self::Press),
variant => Err(crate::ParseError::InvalidVariant("ButtonState", variant)),
}
}
fn as_arg(&self) -> crate::Arg<'_> {
crate::Arg::Uint32(*self as u32)
}
fn enum_name(&self) -> Option<(&'static str, &'static str)> {
Some((
"button_state",
match self {
Self::Released => "released",
Self::Press => "press",
},
))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
Button {
button: u32,
state: ButtonState,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("button"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let button = _bytes.read_arg()?;
let state = _bytes.read_arg()?;
Ok(Self::Button { button, state })
}
opcode => Err(crate::ParseError::InvalidOpcode("button", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::Button { button, state } => {
args.push(button.as_arg());
args.push(state.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use button::Button;
pub mod keyboard {
#[derive(Clone, Debug)]
pub struct Keyboard(pub(crate) crate::Object);
impl crate::private::Sealed for Keyboard {}
impl crate::Interface for Keyboard {
const NAME: &'static str = "ei_keyboard";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Keyboard {}
impl Keyboard {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn keymap(
&self,
keymap_type: KeymapType,
size: u32,
keymap: std::os::unix::io::BorrowedFd,
) -> () {
let args = &[
crate::Arg::Uint32(keymap_type.into()),
crate::Arg::Uint32(size.into()),
crate::Arg::Fd(keymap.into()),
];
self.0.request(1, args);
()
}
pub fn key(&self, key: u32, state: KeyState) -> () {
let args = &[
crate::Arg::Uint32(key.into()),
crate::Arg::Uint32(state.into()),
];
self.0.request(2, args);
()
}
pub fn modifiers(
&self,
serial: u32,
depressed: u32,
locked: u32,
latched: u32,
group: u32,
) -> () {
let args = &[
crate::Arg::Uint32(serial.into()),
crate::Arg::Uint32(depressed.into()),
crate::Arg::Uint32(locked.into()),
crate::Arg::Uint32(latched.into()),
crate::Arg::Uint32(group.into()),
];
self.0.request(3, args);
()
}
}
#[derive(Clone, Copy, Debug)]
pub enum KeyState {
Released = 0,
Press = 1,
}
impl From<KeyState> for u32 {
fn from(value: KeyState) -> u32 {
value as u32
}
}
impl crate::OwnedArg for KeyState {
fn parse(buf: &mut crate::ByteStream) -> Result<Self, crate::ParseError> {
match u32::parse(buf)? {
0 => Ok(Self::Released),
1 => Ok(Self::Press),
variant => Err(crate::ParseError::InvalidVariant("KeyState", variant)),
}
}
fn as_arg(&self) -> crate::Arg<'_> {
crate::Arg::Uint32(*self as u32)
}
fn enum_name(&self) -> Option<(&'static str, &'static str)> {
Some((
"key_state",
match self {
Self::Released => "released",
Self::Press => "press",
},
))
}
}
#[derive(Clone, Copy, Debug)]
pub enum KeymapType {
Xkb = 1,
}
impl From<KeymapType> for u32 {
fn from(value: KeymapType) -> u32 {
value as u32
}
}
impl crate::OwnedArg for KeymapType {
fn parse(buf: &mut crate::ByteStream) -> Result<Self, crate::ParseError> {
match u32::parse(buf)? {
1 => Ok(Self::Xkb),
variant => Err(crate::ParseError::InvalidVariant("KeymapType", variant)),
}
}
fn as_arg(&self) -> crate::Arg<'_> {
crate::Arg::Uint32(*self as u32)
}
fn enum_name(&self) -> Option<(&'static str, &'static str)> {
Some((
"keymap_type",
match self {
Self::Xkb => "xkb",
},
))
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
Key {
key: u32,
state: KeyState,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("key"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let key = _bytes.read_arg()?;
let state = _bytes.read_arg()?;
Ok(Self::Key { key, state })
}
opcode => Err(crate::ParseError::InvalidOpcode("keyboard", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::Key { key, state } => {
args.push(key.as_arg());
args.push(state.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use keyboard::Keyboard;
pub mod touchscreen {
#[derive(Clone, Debug)]
pub struct Touchscreen(pub(crate) crate::Object);
impl crate::private::Sealed for Touchscreen {}
impl crate::Interface for Touchscreen {
const NAME: &'static str = "ei_touchscreen";
const VERSION: u32 = 1;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> crate::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Touchscreen {}
impl Touchscreen {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[crate::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend().remove_id(self.0.id());
()
}
pub fn down(&self, touchid: u32, x: f32, y: f32) -> () {
let args = &[
crate::Arg::Uint32(touchid.into()),
crate::Arg::Float(x.into()),
crate::Arg::Float(y.into()),
];
self.0.request(1, args);
()
}
pub fn motion(&self, touchid: u32, x: f32, y: f32) -> () {
let args = &[
crate::Arg::Uint32(touchid.into()),
crate::Arg::Float(x.into()),
crate::Arg::Float(y.into()),
];
self.0.request(2, args);
()
}
pub fn up(&self, touchid: u32) -> () {
let args = &[crate::Arg::Uint32(touchid.into())];
self.0.request(3, args);
()
}
}
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Release,
Down {
touchid: u32,
x: f32,
y: f32,
},
Motion {
touchid: u32,
x: f32,
y: f32,
},
Up {
touchid: u32,
},
}
impl Request {
pub(super) fn op_name(operand: u32) -> Option<&'static str> {
match operand {
0 => Some("release"),
1 => Some("down"),
2 => Some("motion"),
3 => Some("up"),
_ => None,
}
}
pub(super) fn parse(
operand: u32,
_bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let touchid = _bytes.read_arg()?;
let x = _bytes.read_arg()?;
let y = _bytes.read_arg()?;
Ok(Self::Down { touchid, x, y })
}
2 => {
let touchid = _bytes.read_arg()?;
let x = _bytes.read_arg()?;
let y = _bytes.read_arg()?;
Ok(Self::Motion { touchid, x, y })
}
3 => {
let touchid = _bytes.read_arg()?;
Ok(Self::Up { touchid })
}
opcode => Err(crate::ParseError::InvalidOpcode("touchscreen", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<crate::Arg<'_>> {
use crate::{arg::OwnedArg, Interface};
let mut args = Vec::new();
match self {
Self::Release => {}
Self::Down { touchid, x, y } => {
args.push(touchid.as_arg());
args.push(x.as_arg());
args.push(y.as_arg());
}
Self::Motion { touchid, x, y } => {
args.push(touchid.as_arg());
args.push(x.as_arg());
args.push(y.as_arg());
}
Self::Up { touchid } => {
args.push(touchid.as_arg());
}
_ => unreachable!(),
}
args
}
}
}
pub use touchscreen::Touchscreen;
#[non_exhaustive]
#[derive(Debug)]
pub enum Request {
Handshake(handshake::Handshake, handshake::Request),
Connection(connection::Connection, connection::Request),
Callback(callback::Callback, callback::Request),
Pingpong(pingpong::Pingpong, pingpong::Request),
Seat(seat::Seat, seat::Request),
Device(device::Device, device::Request),
Pointer(pointer::Pointer, pointer::Request),
PointerAbsolute(pointer_absolute::PointerAbsolute, pointer_absolute::Request),
Scroll(scroll::Scroll, scroll::Request),
Button(button::Button, button::Request),
Keyboard(keyboard::Keyboard, keyboard::Request),
Touchscreen(touchscreen::Touchscreen, touchscreen::Request),
}
impl Request {
pub(crate) fn op_name(interface: &str, operand: u32) -> Option<&'static str> {
match interface {
"ei_handshake" => handshake::Request::op_name(operand),
"ei_connection" => connection::Request::op_name(operand),
"ei_callback" => callback::Request::op_name(operand),
"ei_pingpong" => pingpong::Request::op_name(operand),
"ei_seat" => seat::Request::op_name(operand),
"ei_device" => device::Request::op_name(operand),
"ei_pointer" => pointer::Request::op_name(operand),
"ei_pointer_absolute" => pointer_absolute::Request::op_name(operand),
"ei_scroll" => scroll::Request::op_name(operand),
"ei_button" => button::Request::op_name(operand),
"ei_keyboard" => keyboard::Request::op_name(operand),
"ei_touchscreen" => touchscreen::Request::op_name(operand),
_ => None,
}
}
pub(crate) fn parse(
id: u64,
interface: &str,
operand: u32,
bytes: &mut crate::ByteStream,
) -> Result<Self, crate::ParseError> {
match interface {
"ei_handshake" => Ok(Self::Handshake(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
handshake::Request::parse(operand, bytes)?,
)),
"ei_connection" => Ok(Self::Connection(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
connection::Request::parse(operand, bytes)?,
)),
"ei_callback" => Ok(Self::Callback(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
callback::Request::parse(operand, bytes)?,
)),
"ei_pingpong" => Ok(Self::Pingpong(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
pingpong::Request::parse(operand, bytes)?,
)),
"ei_seat" => Ok(Self::Seat(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
seat::Request::parse(operand, bytes)?,
)),
"ei_device" => Ok(Self::Device(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
device::Request::parse(operand, bytes)?,
)),
"ei_pointer" => Ok(Self::Pointer(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
pointer::Request::parse(operand, bytes)?,
)),
"ei_pointer_absolute" => Ok(Self::PointerAbsolute(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
pointer_absolute::Request::parse(operand, bytes)?,
)),
"ei_scroll" => Ok(Self::Scroll(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
scroll::Request::parse(operand, bytes)?,
)),
"ei_button" => Ok(Self::Button(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
button::Request::parse(operand, bytes)?,
)),
"ei_keyboard" => Ok(Self::Keyboard(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
keyboard::Request::parse(operand, bytes)?,
)),
"ei_touchscreen" => Ok(Self::Touchscreen(
crate::Object::new(bytes.backend().clone(), id, false).downcast_unchecked(),
touchscreen::Request::parse(operand, bytes)?,
)),
_ => Err(crate::ParseError::InvalidInterface),
}
}
}
impl crate::MessageEnum for Request {
fn args(&self) -> Vec<crate::Arg<'_>> {
match self {
Self::Handshake(_, x) => x.args(),
Self::Connection(_, x) => x.args(),
Self::Callback(_, x) => x.args(),
Self::Pingpong(_, x) => x.args(),
Self::Seat(_, x) => x.args(),
Self::Device(_, x) => x.args(),
Self::Pointer(_, x) => x.args(),
Self::PointerAbsolute(_, x) => x.args(),
Self::Scroll(_, x) => x.args(),
Self::Button(_, x) => x.args(),
Self::Keyboard(_, x) => x.args(),
Self::Touchscreen(_, x) => x.args(),
}
}
}