#![allow(
unused_imports,
unused_parens,
clippy::useless_conversion,
clippy::double_parens,
clippy::match_single_binding,
clippy::unused_unit
)]
use crate::wire;
pub mod handshake {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Handshake(pub(crate) crate::Object);
impl Handshake {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Handshake {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Handshake {}
impl Handshake {
pub fn handshake_version(&self, version: u32) -> () {
let args = &[wire::Arg::Uint32(version.into())];
self.0.request(0, args);
()
}
pub fn interface_version(&self, name: &str, version: u32) -> () {
let args = &[
wire::Arg::String(name.into()),
wire::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_weak()
.new_object("ei_connection".to_string(), version);
let args = &[
wire::Arg::Uint32(serial.into()),
wire::Arg::NewId(connection.id().into()),
wire::Arg::Uint32(version.into()),
];
self.0.request(2, args);
self.0.backend_weak().remove_id(self.0.id());
(super::connection::Connection(connection))
}
}
pub use crate::eiproto_enum::handshake::ContextType;
#[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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("handshake", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Connection(pub(crate) crate::Object);
impl Connection {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Connection {}
impl wire::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) -> wire::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 = &[
wire::Arg::Uint32(last_serial.into()),
wire::Arg::Uint32(reason.into()),
wire::Arg::String(explanation.into()),
];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn seat(&self, version: u32) -> (super::seat::Seat) {
let seat = self
.0
.backend_weak()
.new_object("ei_seat".to_string(), version);
let args = &[
wire::Arg::NewId(seat.id().into()),
wire::Arg::Uint32(version.into()),
];
self.0.request(1, args);
(super::seat::Seat(seat))
}
pub fn invalid_object(&self, last_serial: u32, invalid_id: u64) -> () {
let args = &[
wire::Arg::Uint32(last_serial.into()),
wire::Arg::Uint64(invalid_id.into()),
];
self.0.request(2, args);
()
}
pub fn ping(&self, version: u32) -> (super::pingpong::Pingpong) {
let ping = self
.0
.backend_weak()
.new_object("ei_pingpong".to_string(), version);
let args = &[
wire::Arg::NewId(ping.id().into()),
wire::Arg::Uint32(version.into()),
];
self.0.request(3, args);
(super::pingpong::Pingpong(ping))
}
}
pub use crate::eiproto_enum::connection::DisconnectReason;
#[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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("connection", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Callback(pub(crate) crate::Object);
impl Callback {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Callback {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Callback {}
impl Callback {
pub fn done(&self, callback_data: u64) -> () {
let args = &[wire::Arg::Uint64(callback_data.into())];
self.0.request(0, args);
self.0.backend_weak().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 wire::ByteStream,
) -> Result<Self, wire::ParseError> {
match operand {
opcode => Err(wire::ParseError::InvalidOpcode("callback", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::OwnedArg, Interface};
let mut args = Vec::new();
match self {
_ => unreachable!(),
}
args
}
}
}
pub use callback::Callback;
pub mod pingpong {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Pingpong(pub(crate) crate::Object);
impl Pingpong {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Pingpong {}
impl wire::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) -> wire::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 wire::ByteStream,
) -> Result<Self, wire::ParseError> {
match operand {
0 => {
let callback_data = _bytes.read_arg()?;
Ok(Self::Done { callback_data })
}
opcode => Err(wire::ParseError::InvalidOpcode("pingpong", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Seat(pub(crate) crate::Object);
impl Seat {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Seat {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Seat {}
impl Seat {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn name(&self, name: &str) -> () {
let args = &[wire::Arg::String(name.into())];
self.0.request(1, args);
()
}
pub fn capability(&self, mask: u64, interface: &str) -> () {
let args = &[
wire::Arg::Uint64(mask.into()),
wire::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_weak()
.new_object("ei_device".to_string(), version);
let args = &[
wire::Arg::NewId(device.id().into()),
wire::Arg::Uint32(version.into()),
];
self.0.request(4, args);
(super::device::Device(device))
}
}
#[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 wire::ByteStream,
) -> Result<Self, wire::ParseError> {
match operand {
0 => Ok(Self::Release),
1 => {
let capabilities = _bytes.read_arg()?;
Ok(Self::Bind { capabilities })
}
opcode => Err(wire::ParseError::InvalidOpcode("seat", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Device(pub(crate) crate::Object);
impl Device {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Device {}
impl wire::Interface for Device {
const NAME: &'static str = "ei_device";
const VERSION: u32 = 2;
const CLIENT_SIDE: bool = false;
type Incoming = Request;
fn new_unchecked(object: crate::Object) -> Self {
Self(object)
}
fn as_arg(&self) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Device {}
impl Device {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn name(&self, name: &str) -> () {
let args = &[wire::Arg::String(name.into())];
self.0.request(1, args);
()
}
pub fn device_type(&self, device_type: DeviceType) -> () {
let args = &[wire::Arg::Uint32(device_type.into())];
self.0.request(2, args);
()
}
pub fn dimensions(&self, width: u32, height: u32) -> () {
let args = &[
wire::Arg::Uint32(width.into()),
wire::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 = &[
wire::Arg::Uint32(offset_x.into()),
wire::Arg::Uint32(offset_y.into()),
wire::Arg::Uint32(width.into()),
wire::Arg::Uint32(hight.into()),
wire::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_weak()
.new_object(InterfaceName::NAME.to_string(), version);
let args = &[
wire::Arg::NewId(object.id().into()),
wire::Arg::String(InterfaceName::NAME),
wire::Arg::Uint32(version.into()),
];
self.0.request(5, args);
(object.downcast_unchecked())
}
pub fn done(&self) -> () {
let args = &[];
self.0.request(6, args);
()
}
pub fn resumed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(7, args);
()
}
pub fn paused(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(8, args);
()
}
pub fn start_emulating(&self, serial: u32, sequence: u32) -> () {
let args = &[
wire::Arg::Uint32(serial.into()),
wire::Arg::Uint32(sequence.into()),
];
self.0.request(9, args);
()
}
pub fn stop_emulating(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(10, args);
()
}
pub fn frame(&self, serial: u32, timestamp: u64) -> () {
let args = &[
wire::Arg::Uint32(serial.into()),
wire::Arg::Uint64(timestamp.into()),
];
self.0.request(11, args);
()
}
pub fn region_mapping_id(&self, mapping_id: &str) -> () {
let args = &[wire::Arg::String(mapping_id.into())];
self.0.request(12, args);
()
}
}
pub use crate::eiproto_enum::device::DeviceType;
#[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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("device", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Pointer(pub(crate) crate::Object);
impl Pointer {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Pointer {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Pointer {}
impl Pointer {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn motion_relative(&self, x: f32, y: f32) -> () {
let args = &[wire::Arg::Float(x.into()), wire::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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("pointer", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct PointerAbsolute(pub(crate) crate::Object);
impl PointerAbsolute {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for PointerAbsolute {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for PointerAbsolute {}
impl PointerAbsolute {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn motion_absolute(&self, x: f32, y: f32) -> () {
let args = &[wire::Arg::Float(x.into()), wire::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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("pointer_absolute", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Scroll(pub(crate) crate::Object);
impl Scroll {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Scroll {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Scroll {}
impl Scroll {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn scroll(&self, x: f32, y: f32) -> () {
let args = &[wire::Arg::Float(x.into()), wire::Arg::Float(y.into())];
self.0.request(1, args);
()
}
pub fn scroll_discrete(&self, x: i32, y: i32) -> () {
let args = &[wire::Arg::Int32(x.into()), wire::Arg::Int32(y.into())];
self.0.request(2, args);
()
}
pub fn scroll_stop(&self, x: u32, y: u32, is_cancel: u32) -> () {
let args = &[
wire::Arg::Uint32(x.into()),
wire::Arg::Uint32(y.into()),
wire::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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("scroll", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Button(pub(crate) crate::Object);
impl Button {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Button {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Button {}
impl Button {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn button(&self, button: u32, state: ButtonState) -> () {
let args = &[
wire::Arg::Uint32(button.into()),
wire::Arg::Uint32(state.into()),
];
self.0.request(1, args);
()
}
}
pub use crate::eiproto_enum::button::ButtonState;
#[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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("button", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Keyboard(pub(crate) crate::Object);
impl Keyboard {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Keyboard {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Keyboard {}
impl Keyboard {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn keymap(
&self,
keymap_type: KeymapType,
size: u32,
keymap: std::os::unix::io::BorrowedFd,
) -> () {
let args = &[
wire::Arg::Uint32(keymap_type.into()),
wire::Arg::Uint32(size.into()),
wire::Arg::Fd(keymap.into()),
];
self.0.request(1, args);
()
}
pub fn key(&self, key: u32, state: KeyState) -> () {
let args = &[
wire::Arg::Uint32(key.into()),
wire::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 = &[
wire::Arg::Uint32(serial.into()),
wire::Arg::Uint32(depressed.into()),
wire::Arg::Uint32(locked.into()),
wire::Arg::Uint32(latched.into()),
wire::Arg::Uint32(group.into()),
];
self.0.request(3, args);
()
}
}
pub use crate::eiproto_enum::keyboard::KeyState;
pub use crate::eiproto_enum::keyboard::KeymapType;
#[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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("keyboard", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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 {
use crate::wire;
#[derive(Clone, Debug, Hash, Eq, PartialEq)]
pub struct Touchscreen(pub(crate) crate::Object);
impl Touchscreen {
pub fn version(&self) -> u32 {
self.0.version()
}
}
impl crate::private::Sealed for Touchscreen {}
impl wire::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) -> wire::Arg<'_> {
self.0.as_arg()
}
}
impl crate::eis::Interface for Touchscreen {}
impl Touchscreen {
pub fn destroyed(&self, serial: u32) -> () {
let args = &[wire::Arg::Uint32(serial.into())];
self.0.request(0, args);
self.0.backend_weak().remove_id(self.0.id());
()
}
pub fn down(&self, touchid: u32, x: f32, y: f32) -> () {
let args = &[
wire::Arg::Uint32(touchid.into()),
wire::Arg::Float(x.into()),
wire::Arg::Float(y.into()),
];
self.0.request(1, args);
()
}
pub fn motion(&self, touchid: u32, x: f32, y: f32) -> () {
let args = &[
wire::Arg::Uint32(touchid.into()),
wire::Arg::Float(x.into()),
wire::Arg::Float(y.into()),
];
self.0.request(2, args);
()
}
pub fn up(&self, touchid: u32) -> () {
let args = &[wire::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 wire::ByteStream,
) -> Result<Self, wire::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(wire::ParseError::InvalidOpcode("touchscreen", opcode)),
}
}
#[allow(
unused_imports,
unused_mut,
unused_variables,
unreachable_code,
unreachable_patterns
)]
pub(super) fn args(&self) -> Vec<wire::Arg<'_>> {
use crate::{wire::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(
object: crate::Object,
operand: u32,
bytes: &mut wire::ByteStream,
) -> Result<Self, wire::ParseError> {
match object.interface() {
"ei_handshake" => Ok(Self::Handshake(
object.downcast_unchecked(),
handshake::Request::parse(operand, bytes)?,
)),
"ei_connection" => Ok(Self::Connection(
object.downcast_unchecked(),
connection::Request::parse(operand, bytes)?,
)),
"ei_callback" => Ok(Self::Callback(
object.downcast_unchecked(),
callback::Request::parse(operand, bytes)?,
)),
"ei_pingpong" => Ok(Self::Pingpong(
object.downcast_unchecked(),
pingpong::Request::parse(operand, bytes)?,
)),
"ei_seat" => Ok(Self::Seat(
object.downcast_unchecked(),
seat::Request::parse(operand, bytes)?,
)),
"ei_device" => Ok(Self::Device(
object.downcast_unchecked(),
device::Request::parse(operand, bytes)?,
)),
"ei_pointer" => Ok(Self::Pointer(
object.downcast_unchecked(),
pointer::Request::parse(operand, bytes)?,
)),
"ei_pointer_absolute" => Ok(Self::PointerAbsolute(
object.downcast_unchecked(),
pointer_absolute::Request::parse(operand, bytes)?,
)),
"ei_scroll" => Ok(Self::Scroll(
object.downcast_unchecked(),
scroll::Request::parse(operand, bytes)?,
)),
"ei_button" => Ok(Self::Button(
object.downcast_unchecked(),
button::Request::parse(operand, bytes)?,
)),
"ei_keyboard" => Ok(Self::Keyboard(
object.downcast_unchecked(),
keyboard::Request::parse(operand, bytes)?,
)),
"ei_touchscreen" => Ok(Self::Touchscreen(
object.downcast_unchecked(),
touchscreen::Request::parse(operand, bytes)?,
)),
intr => Err(wire::ParseError::InvalidInterface(intr.to_owned())),
}
}
}
impl wire::MessageEnum for Request {
fn args(&self) -> Vec<wire::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(),
}
}
}