use {super::super::all_types::*, crate::builder::prelude::*};
static INTERFACE: wl_interface = wl_interface {
name: c"wl_seat".as_ptr(),
version: 10,
method_count: 2,
methods: {
static MESSAGES: [wl_message; 2] = [
wl_message {
name: c"get_keyboard".as_ptr(),
signature: c"n".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 1] =
[Some(WlKeyboard::WL_INTERFACE)];
TYPES.as_ptr().cast()
},
},
wl_message {
name: c"release".as_ptr(),
signature: c"".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 0] = [];
TYPES.as_ptr().cast()
},
},
];
MESSAGES.as_ptr()
},
event_count: 1,
events: {
static MESSAGES: [wl_message; 1] = [wl_message {
name: c"capabilities".as_ptr(),
signature: c"u".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 1] = [None];
TYPES.as_ptr().cast()
},
}];
MESSAGES.as_ptr()
},
};
#[derive(Clone, Eq, PartialEq)]
#[repr(transparent)]
pub struct WlSeat {
proxy: UntypedOwnedProxy,
}
#[derive(Eq, PartialEq)]
#[repr(transparent)]
pub struct WlSeatRef {
proxy: UntypedBorrowedProxy,
}
unsafe impl UntypedOwnedProxyWrapper for WlSeat {}
unsafe impl OwnedProxy for WlSeat {
const INTERFACE: &'static str = "wl_seat";
const WL_INTERFACE: &'static wl_interface = &INTERFACE;
const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
private::EventHandler(private::NoOpEventHandler);
const MAX_VERSION: u32 = 10;
type Borrowed = WlSeatRef;
type Api = private::ProxyApi;
type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
}
unsafe impl UntypedBorrowedProxyWrapper for WlSeatRef {}
unsafe impl BorrowedProxy for WlSeatRef {
type Owned = WlSeat;
}
impl Deref for WlSeat {
type Target = WlSeatRef;
fn deref(&self) -> &Self::Target {
proxy::low_level::deref(self)
}
}
mod private {
pub struct ProxyApi;
#[allow(dead_code)]
pub struct EventHandler<H>(pub(super) H);
#[allow(dead_code)]
pub struct NoOpEventHandler;
}
impl Debug for WlSeat {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "wl_seat#{}", self.proxy.id())
}
}
impl Debug for WlSeatRef {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "wl_seat#{}", self.proxy.id())
}
}
impl PartialEq<WlSeatRef> for WlSeat {
fn eq(&self, other: &WlSeatRef) -> bool {
self.proxy == other.proxy
}
}
impl PartialEq<WlSeat> for WlSeatRef {
fn eq(&self, other: &WlSeat) -> bool {
self.proxy == other.proxy
}
}
#[allow(dead_code)]
impl WlSeat {
#[allow(dead_code)]
pub const REQ__GET_KEYBOARD__SINCE: u32 = 1;
#[inline]
pub fn get_keyboard(&self) -> WlKeyboard {
let mut args = [wl_argument { n: 0 }];
let data = unsafe {
self.proxy
.send_constructor::<false>(0, &mut args, WlKeyboard::WL_INTERFACE, None)
};
unsafe { proxy::low_level::from_untyped_owned(data) }
}
#[allow(dead_code)]
pub const REQ__RELEASE__SINCE: u32 = 5;
#[inline]
pub fn release(&self) {
let mut args = [];
unsafe {
self.proxy.send_destructor(1, &mut args);
}
}
}
#[allow(dead_code)]
impl WlSeatRef {
#[inline]
pub fn get_keyboard(&self, _queue: &Queue) -> WlKeyboard {
let mut args = [wl_argument { n: 0 }];
let data = unsafe {
self.proxy
.send_constructor(_queue, 0, &mut args, WlKeyboard::WL_INTERFACE, None)
};
unsafe { proxy::low_level::from_untyped_owned(data) }
}
}
impl WlSeat {
#[allow(dead_code)]
pub const EVT__CAPABILITIES__SINCE: u32 = 1;
}
#[allow(dead_code)]
pub trait WlSeatEventHandler {
#[inline]
fn capabilities(&self, _slf: &WlSeatRef, capabilities: WlSeatCapability) {
let _ = capabilities;
}
}
impl WlSeatEventHandler for private::NoOpEventHandler {}
unsafe impl<H> EventHandler for private::EventHandler<H>
where
H: WlSeatEventHandler,
{
const WL_INTERFACE: &'static wl_interface = &INTERFACE;
#[allow(unused_variables)]
unsafe fn handle_event(
&self,
queue: &Queue,
data: *mut u8,
slf: &UntypedBorrowedProxy,
opcode: u32,
args: *mut wl_argument,
) {
let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlSeatRef>(slf) };
match opcode {
0 => {
let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
let arg0 = unsafe { WlSeatCapability(args[0].u) };
self.0.capabilities(slf, arg0);
}
_ => {
invalid_opcode("wl_seat", opcode);
}
}
}
}
impl<H> CreateEventHandler<H> for private::ProxyApi
where
H: WlSeatEventHandler,
{
type EventHandler = private::EventHandler<H>;
#[inline]
fn create_event_handler(handler: H) -> Self::EventHandler {
private::EventHandler(handler)
}
}
impl WlSeat {
#[allow(dead_code)]
pub const ENM__CAPABILITY_KEYBOARD__SINCE: u32 = 1;
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
#[allow(dead_code)]
pub struct WlSeatCapability(pub u32);
#[derive(Clone, Debug)]
pub struct WlSeatCapabilityIter(pub u32);
impl WlSeatCapability {
#[allow(dead_code)]
pub const KEYBOARD: Self = Self(2);
}
#[allow(dead_code)]
impl WlSeatCapability {
#[inline]
pub const fn empty() -> Self {
Self(0)
}
#[inline]
#[must_use]
pub const fn is_empty(self) -> bool {
self.0 == 0
}
#[inline]
#[must_use]
pub const fn contains(self, other: Self) -> bool {
self.0 & other.0 == other.0
}
#[inline]
#[must_use]
pub const fn intersects(self, other: Self) -> bool {
self.0 & other.0 != 0
}
#[inline]
pub const fn insert(&mut self, other: Self) {
*self = self.union(other);
}
#[inline]
pub const fn remove(&mut self, other: Self) {
*self = self.difference(other);
}
#[inline]
pub const fn toggle(&mut self, other: Self) {
*self = self.symmetric_difference(other);
}
#[inline]
pub const fn set(&mut self, other: Self, value: bool) {
if value {
self.insert(other);
} else {
self.remove(other);
}
}
#[inline]
#[must_use]
pub const fn intersection(self, other: Self) -> Self {
Self(self.0 & other.0)
}
#[inline]
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[inline]
#[must_use]
pub const fn difference(self, other: Self) -> Self {
Self(self.0 & !other.0)
}
#[inline]
#[must_use]
pub const fn complement(self) -> Self {
Self(!self.0)
}
#[inline]
#[must_use]
pub const fn symmetric_difference(self, other: Self) -> Self {
Self(self.0 ^ other.0)
}
#[inline]
pub const fn all_known() -> Self {
#[allow(clippy::eq_op, clippy::identity_op)]
Self(0 | 2)
}
}
impl Iterator for WlSeatCapabilityIter {
type Item = WlSeatCapability;
fn next(&mut self) -> Option<Self::Item> {
if self.0 == 0 {
return None;
}
let bit = 1 << self.0.trailing_zeros();
self.0 &= !bit;
Some(WlSeatCapability(bit))
}
}
impl IntoIterator for WlSeatCapability {
type Item = WlSeatCapability;
type IntoIter = WlSeatCapabilityIter;
fn into_iter(self) -> Self::IntoIter {
WlSeatCapabilityIter(self.0)
}
}
impl BitAnd for WlSeatCapability {
type Output = Self;
fn bitand(self, rhs: Self) -> Self::Output {
self.intersection(rhs)
}
}
impl BitAndAssign for WlSeatCapability {
fn bitand_assign(&mut self, rhs: Self) {
*self = self.intersection(rhs);
}
}
impl BitOr for WlSeatCapability {
type Output = Self;
fn bitor(self, rhs: Self) -> Self::Output {
self.union(rhs)
}
}
impl BitOrAssign for WlSeatCapability {
fn bitor_assign(&mut self, rhs: Self) {
*self = self.union(rhs);
}
}
impl BitXor for WlSeatCapability {
type Output = Self;
fn bitxor(self, rhs: Self) -> Self::Output {
self.symmetric_difference(rhs)
}
}
impl BitXorAssign for WlSeatCapability {
fn bitxor_assign(&mut self, rhs: Self) {
*self = self.symmetric_difference(rhs);
}
}
impl Sub for WlSeatCapability {
type Output = Self;
fn sub(self, rhs: Self) -> Self::Output {
self.difference(rhs)
}
}
impl SubAssign for WlSeatCapability {
fn sub_assign(&mut self, rhs: Self) {
*self = self.difference(rhs);
}
}
impl Not for WlSeatCapability {
type Output = Self;
fn not(self) -> Self::Output {
self.complement()
}
}
impl Debug for WlSeatCapability {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let mut v = self.0;
let mut first = true;
if v & 2 == 2 {
v &= !2;
if first {
first = false;
} else {
f.write_str(" | ")?;
}
f.write_str("KEYBOARD")?;
}
if v != 0 {
if first {
first = false;
} else {
f.write_str(" | ")?;
}
write!(f, "0x{v:032x}")?;
}
if first {
f.write_str("0")?;
}
Ok(())
}
}
pub mod event_handlers {
use super::*;
pub struct Capabilities<F>(F);
impl<F> WlSeatEventHandler for Capabilities<F>
where
F: Fn(&WlSeatRef, WlSeatCapability),
{
#[inline]
fn capabilities(&self, _slf: &WlSeatRef, capabilities: WlSeatCapability) {
self.0(_slf, capabilities)
}
}
impl WlSeat {
#[allow(dead_code)]
pub fn on_capabilities<F>(f: F) -> Capabilities<F>
where
F: Fn(&WlSeatRef, WlSeatCapability),
{
Capabilities(f)
}
}
}