simple_window/common/protocols/wayland/
wl_compositor.rs1use {super::super::all_types::*, ::wl_client::builder::prelude::*};
8
9static INTERFACE: wl_interface = wl_interface {
10 name: c"wl_compositor".as_ptr(),
11 version: 6,
12 method_count: 2,
13 methods: {
14 static MESSAGES: [wl_message; 2] = [
15 wl_message {
16 name: c"create_surface".as_ptr(),
17 signature: c"n".as_ptr(),
18 types: {
19 static TYPES: [Option<&'static wl_interface>; 1] =
20 [Some(WlSurface::WL_INTERFACE)];
21 TYPES.as_ptr().cast()
22 },
23 },
24 wl_message {
25 name: c"create_region".as_ptr(),
26 signature: c"n".as_ptr(),
27 types: {
28 static TYPES: [Option<&'static wl_interface>; 1] =
29 [Some(WlRegion::WL_INTERFACE)];
30 TYPES.as_ptr().cast()
31 },
32 },
33 ];
34 MESSAGES.as_ptr()
35 },
36 event_count: 0,
37 events: ptr::null(),
38};
39
40#[derive(Clone, Eq, PartialEq)]
44#[repr(transparent)]
45pub struct WlCompositor {
46 proxy: UntypedOwnedProxy,
48}
49
50#[derive(Eq, PartialEq)]
54#[repr(transparent)]
55pub struct WlCompositorRef {
56 proxy: UntypedBorrowedProxy,
58}
59
60unsafe impl UntypedOwnedProxyWrapper for WlCompositor {}
62
63unsafe impl OwnedProxy for WlCompositor {
66 const INTERFACE: &'static str = "wl_compositor";
67 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
68 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
69 private::EventHandler(private::NoOpEventHandler);
70 const MAX_VERSION: u32 = 6;
71
72 type Borrowed = WlCompositorRef;
73 type Api = private::ProxyApi;
74 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
75}
76
77unsafe impl UntypedBorrowedProxyWrapper for WlCompositorRef {}
79
80unsafe impl BorrowedProxy for WlCompositorRef {
82 type Owned = WlCompositor;
83}
84
85impl Deref for WlCompositor {
86 type Target = WlCompositorRef;
87
88 fn deref(&self) -> &Self::Target {
89 proxy::low_level::deref(self)
90 }
91}
92
93mod private {
94 pub struct ProxyApi;
95
96 #[allow(dead_code)]
97 pub struct EventHandler<H>(pub(super) H);
98
99 #[allow(dead_code)]
100 pub struct NoOpEventHandler;
101}
102
103impl Debug for WlCompositor {
104 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
105 write!(f, "wl_compositor#{}", self.proxy.id())
106 }
107}
108
109impl Debug for WlCompositorRef {
110 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
111 write!(f, "wl_compositor#{}", self.proxy.id())
112 }
113}
114
115impl PartialEq<WlCompositorRef> for WlCompositor {
116 fn eq(&self, other: &WlCompositorRef) -> bool {
117 self.proxy == other.proxy
118 }
119}
120
121impl PartialEq<WlCompositor> for WlCompositorRef {
122 fn eq(&self, other: &WlCompositor) -> bool {
123 self.proxy == other.proxy
124 }
125}
126
127#[allow(dead_code)]
128impl WlCompositor {
129 #[allow(dead_code)]
131 pub const REQ__CREATE_SURFACE__SINCE: u32 = 1;
132
133 #[inline]
137 pub fn create_surface(&self) -> WlSurface {
138 let mut args = [wl_argument { n: 0 }];
139 let data = unsafe {
144 self.proxy
145 .send_constructor::<false>(0, &mut args, WlSurface::WL_INTERFACE, None)
146 };
147 unsafe { proxy::low_level::from_untyped_owned(data) }
149 }
150
151 #[allow(dead_code)]
153 pub const REQ__CREATE_REGION__SINCE: u32 = 1;
154
155 #[inline]
159 pub fn create_region(&self) -> WlRegion {
160 let mut args = [wl_argument { n: 0 }];
161 let data = unsafe {
166 self.proxy
167 .send_constructor::<false>(1, &mut args, WlRegion::WL_INTERFACE, None)
168 };
169 unsafe { proxy::low_level::from_untyped_owned(data) }
171 }
172}
173
174#[allow(dead_code)]
175impl WlCompositorRef {
176 #[inline]
184 pub fn create_surface(&self, _queue: &Queue) -> WlSurface {
185 let mut args = [wl_argument { n: 0 }];
186 let data = unsafe {
191 self.proxy
192 .send_constructor(_queue, 0, &mut args, WlSurface::WL_INTERFACE, None)
193 };
194 unsafe { proxy::low_level::from_untyped_owned(data) }
196 }
197
198 #[inline]
206 pub fn create_region(&self, _queue: &Queue) -> WlRegion {
207 let mut args = [wl_argument { n: 0 }];
208 let data = unsafe {
213 self.proxy
214 .send_constructor(_queue, 1, &mut args, WlRegion::WL_INTERFACE, None)
215 };
216 unsafe { proxy::low_level::from_untyped_owned(data) }
218 }
219}
220
221#[allow(dead_code)]
223pub trait WlCompositorEventHandler {}
224
225impl WlCompositorEventHandler for private::NoOpEventHandler {}
226
227unsafe impl<H> EventHandler for private::EventHandler<H>
229where
230 H: WlCompositorEventHandler,
231{
232 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
233
234 #[allow(unused_variables)]
235 unsafe fn handle_event(
236 &self,
237 queue: &Queue,
238 data: *mut u8,
239 slf: &UntypedBorrowedProxy,
240 opcode: u32,
241 args: *mut wl_argument,
242 ) {
243 invalid_opcode("wl_compositor", opcode);
244 }
245}
246
247impl<H> CreateEventHandler<H> for private::ProxyApi
248where
249 H: WlCompositorEventHandler,
250{
251 type EventHandler = private::EventHandler<H>;
252
253 #[inline]
254 fn create_event_handler(handler: H) -> Self::EventHandler {
255 private::EventHandler(handler)
256 }
257}
258
259pub mod event_handlers {
261 use super::*;
262
263 impl WlCompositor {}
264}