use {super::super::all_types::*, ::wl_client::builder::prelude::*};
static INTERFACE: wl_interface = wl_interface {
name: c"xdg_surface".as_ptr(),
version: 6,
method_count: 5,
methods: {
static MESSAGES: [wl_message; 5] = [
wl_message {
name: c"destroy".as_ptr(),
signature: c"".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 0] = [];
TYPES.as_ptr().cast()
},
},
wl_message {
name: c"get_toplevel".as_ptr(),
signature: c"n".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 1] =
[Some(XdgToplevel::WL_INTERFACE)];
TYPES.as_ptr().cast()
},
},
wl_message {
name: c"get_popup".as_ptr(),
signature: c"n?oo".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 3] = [
Some(XdgPopup::WL_INTERFACE),
Some(XdgSurface::WL_INTERFACE),
Some(XdgPositioner::WL_INTERFACE),
];
TYPES.as_ptr().cast()
},
},
wl_message {
name: c"set_window_geometry".as_ptr(),
signature: c"iiii".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 4] = [None, None, None, None];
TYPES.as_ptr().cast()
},
},
wl_message {
name: c"ack_configure".as_ptr(),
signature: c"u".as_ptr(),
types: {
static TYPES: [Option<&'static wl_interface>; 1] = [None];
TYPES.as_ptr().cast()
},
},
];
MESSAGES.as_ptr()
},
event_count: 1,
events: {
static MESSAGES: [wl_message; 1] = [wl_message {
name: c"configure".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 XdgSurface {
proxy: UntypedOwnedProxy,
}
#[derive(Eq, PartialEq)]
#[repr(transparent)]
pub struct XdgSurfaceRef {
proxy: UntypedBorrowedProxy,
}
unsafe impl UntypedOwnedProxyWrapper for XdgSurface {}
unsafe impl OwnedProxy for XdgSurface {
const INTERFACE: &'static str = "xdg_surface";
const WL_INTERFACE: &'static wl_interface = &INTERFACE;
const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
private::EventHandler(private::NoOpEventHandler);
const MAX_VERSION: u32 = 6;
type Borrowed = XdgSurfaceRef;
type Api = private::ProxyApi;
type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
}
unsafe impl UntypedBorrowedProxyWrapper for XdgSurfaceRef {}
unsafe impl BorrowedProxy for XdgSurfaceRef {
type Owned = XdgSurface;
}
impl Deref for XdgSurface {
type Target = XdgSurfaceRef;
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 XdgSurface {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "xdg_surface#{}", self.proxy.id())
}
}
impl Debug for XdgSurfaceRef {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "xdg_surface#{}", self.proxy.id())
}
}
impl PartialEq<XdgSurfaceRef> for XdgSurface {
fn eq(&self, other: &XdgSurfaceRef) -> bool {
self.proxy == other.proxy
}
}
impl PartialEq<XdgSurface> for XdgSurfaceRef {
fn eq(&self, other: &XdgSurface) -> bool {
self.proxy == other.proxy
}
}
#[allow(dead_code)]
impl XdgSurface {
#[allow(dead_code)]
pub const REQ__DESTROY__SINCE: u32 = 1;
#[inline]
pub fn destroy(&self) {
let mut args = [];
unsafe {
self.proxy.send_destructor(0, &mut args);
}
}
#[allow(dead_code)]
pub const REQ__GET_TOPLEVEL__SINCE: u32 = 1;
#[inline]
pub fn get_toplevel(&self) -> XdgToplevel {
let mut args = [wl_argument { n: 0 }];
let data = unsafe {
self.proxy
.send_constructor::<false>(1, &mut args, XdgToplevel::WL_INTERFACE, None)
};
unsafe { proxy::low_level::from_untyped_owned(data) }
}
#[allow(dead_code)]
pub const REQ__GET_POPUP__SINCE: u32 = 1;
#[inline]
pub fn get_popup(
&self,
parent: Option<&XdgSurfaceRef>,
positioner: &XdgPositionerRef,
) -> XdgPopup {
let (arg1, arg2) = (parent, positioner);
let obj1_lock = arg1.map(|arg1| proxy::lock(arg1));
let obj1 = obj1_lock
.map(|obj1_lock| check_argument_proxy("parent", obj1_lock.wl_proxy()))
.unwrap_or(ptr::null_mut());
let obj2_lock = proxy::lock(arg2);
let obj2 = check_argument_proxy("positioner", obj2_lock.wl_proxy());
let mut args = [
wl_argument { n: 0 },
wl_argument { o: obj1 },
wl_argument { o: obj2 },
];
let data = unsafe {
self.proxy
.send_constructor::<false>(2, &mut args, XdgPopup::WL_INTERFACE, None)
};
unsafe { proxy::low_level::from_untyped_owned(data) }
}
}
#[allow(dead_code)]
impl XdgSurfaceRef {
#[inline]
pub fn get_toplevel(&self, _queue: &Queue) -> XdgToplevel {
let mut args = [wl_argument { n: 0 }];
let data = unsafe {
self.proxy
.send_constructor(_queue, 1, &mut args, XdgToplevel::WL_INTERFACE, None)
};
unsafe { proxy::low_level::from_untyped_owned(data) }
}
#[inline]
pub fn get_popup(
&self,
_queue: &Queue,
parent: Option<&XdgSurfaceRef>,
positioner: &XdgPositionerRef,
) -> XdgPopup {
let (arg1, arg2) = (parent, positioner);
let obj1_lock = arg1.map(|arg1| proxy::lock(arg1));
let obj1 = obj1_lock
.map(|obj1_lock| check_argument_proxy("parent", obj1_lock.wl_proxy()))
.unwrap_or(ptr::null_mut());
let obj2_lock = proxy::lock(arg2);
let obj2 = check_argument_proxy("positioner", obj2_lock.wl_proxy());
let mut args = [
wl_argument { n: 0 },
wl_argument { o: obj1 },
wl_argument { o: obj2 },
];
let data = unsafe {
self.proxy
.send_constructor(_queue, 2, &mut args, XdgPopup::WL_INTERFACE, None)
};
unsafe { proxy::low_level::from_untyped_owned(data) }
}
#[inline]
pub fn set_window_geometry(&self, x: i32, y: i32, width: i32, height: i32) {
let (arg0, arg1, arg2, arg3) = (x, y, width, height);
let mut args = [
wl_argument { i: arg0 },
wl_argument { i: arg1 },
wl_argument { i: arg2 },
wl_argument { i: arg3 },
];
unsafe {
self.proxy.send_request(3, &mut args);
}
}
#[inline]
pub fn ack_configure(&self, serial: u32) {
let (arg0,) = (serial,);
let mut args = [wl_argument { u: arg0 }];
unsafe {
self.proxy.send_request(4, &mut args);
}
}
}
impl XdgSurface {
#[allow(dead_code)]
pub const EVT__CONFIGURE__SINCE: u32 = 1;
}
#[allow(dead_code)]
pub trait XdgSurfaceEventHandler {
type Data: 'static;
#[inline]
fn configure(&self, _data: &mut Self::Data, _slf: &XdgSurfaceRef, serial: u32) {
let _ = serial;
}
}
impl XdgSurfaceEventHandler for private::NoOpEventHandler {
type Data = ();
}
unsafe impl<H> EventHandler for private::EventHandler<H>
where
H: XdgSurfaceEventHandler,
{
const WL_INTERFACE: &'static wl_interface = &INTERFACE;
#[inline]
fn mutable_type() -> Option<(TypeId, &'static str)> {
let id = TypeId::of::<H::Data>();
let name = std::any::type_name::<H::Data>();
Some((id, name))
}
#[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::<XdgSurfaceRef>(slf) };
let data: &mut H::Data = unsafe { &mut *data.cast() };
match opcode {
0 => {
let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
let arg0 = unsafe { args[0].u };
self.0.configure(data, slf, arg0);
}
_ => {
invalid_opcode("xdg_surface", opcode);
}
}
}
}
impl<H> CreateEventHandler<H> for private::ProxyApi
where
H: XdgSurfaceEventHandler,
{
type EventHandler = private::EventHandler<H>;
#[inline]
fn create_event_handler(handler: H) -> Self::EventHandler {
private::EventHandler(handler)
}
}
impl XdgSurface {
#[allow(dead_code)]
pub const ENM__ERROR_NOT_CONSTRUCTED__SINCE: u32 = 1;
#[allow(dead_code)]
pub const ENM__ERROR_ALREADY_CONSTRUCTED__SINCE: u32 = 1;
#[allow(dead_code)]
pub const ENM__ERROR_UNCONFIGURED_BUFFER__SINCE: u32 = 1;
#[allow(dead_code)]
pub const ENM__ERROR_INVALID_SERIAL__SINCE: u32 = 1;
#[allow(dead_code)]
pub const ENM__ERROR_INVALID_SIZE__SINCE: u32 = 1;
#[allow(dead_code)]
pub const ENM__ERROR_DEFUNCT_ROLE_OBJECT__SINCE: u32 = 1;
}
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[allow(dead_code)]
pub struct XdgSurfaceError(pub u32);
impl XdgSurfaceError {
#[allow(dead_code)]
pub const NOT_CONSTRUCTED: Self = Self(1);
#[allow(dead_code)]
pub const ALREADY_CONSTRUCTED: Self = Self(2);
#[allow(dead_code)]
pub const UNCONFIGURED_BUFFER: Self = Self(3);
#[allow(dead_code)]
pub const INVALID_SERIAL: Self = Self(4);
#[allow(dead_code)]
pub const INVALID_SIZE: Self = Self(5);
#[allow(dead_code)]
pub const DEFUNCT_ROLE_OBJECT: Self = Self(6);
}
impl Debug for XdgSurfaceError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
let name = match *self {
Self::NOT_CONSTRUCTED => "NOT_CONSTRUCTED",
Self::ALREADY_CONSTRUCTED => "ALREADY_CONSTRUCTED",
Self::UNCONFIGURED_BUFFER => "UNCONFIGURED_BUFFER",
Self::INVALID_SERIAL => "INVALID_SERIAL",
Self::INVALID_SIZE => "INVALID_SIZE",
Self::DEFUNCT_ROLE_OBJECT => "DEFUNCT_ROLE_OBJECT",
_ => return Debug::fmt(&self.0, f),
};
f.write_str(name)
}
}
pub mod event_handlers {
use super::*;
pub struct Configure<T, F>(F, PhantomData<fn(&mut T)>);
impl<T, F> XdgSurfaceEventHandler for Configure<T, F>
where
T: 'static,
F: Fn(&mut T, &XdgSurfaceRef, u32),
{
type Data = T;
#[inline]
fn configure(&self, _data: &mut T, _slf: &XdgSurfaceRef, serial: u32) {
self.0(_data, _slf, serial)
}
}
impl XdgSurface {
#[allow(dead_code)]
pub fn on_configure<T, F>(f: F) -> Configure<T, F>
where
T: 'static,
F: Fn(&mut T, &XdgSurfaceRef, u32),
{
Configure(f, PhantomData)
}
}
}