1use {super::super::all_types::*, ::wl_client::builder::prelude::*};
13
14static INTERFACE: wl_interface = wl_interface {
15 name: c"zwp_tablet_v2".as_ptr(),
16 version: 1,
17 method_count: 1,
18 methods: {
19 static MESSAGES: [wl_message; 1] = [wl_message {
20 name: c"destroy".as_ptr(),
21 signature: c"".as_ptr(),
22 types: {
23 static TYPES: [Option<&'static wl_interface>; 0] = [];
24 TYPES.as_ptr().cast()
25 },
26 }];
27 MESSAGES.as_ptr()
28 },
29 event_count: 5,
30 events: {
31 static MESSAGES: [wl_message; 5] = [
32 wl_message {
33 name: c"name".as_ptr(),
34 signature: c"s".as_ptr(),
35 types: {
36 static TYPES: [Option<&'static wl_interface>; 1] = [None];
37 TYPES.as_ptr().cast()
38 },
39 },
40 wl_message {
41 name: c"id".as_ptr(),
42 signature: c"uu".as_ptr(),
43 types: {
44 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
45 TYPES.as_ptr().cast()
46 },
47 },
48 wl_message {
49 name: c"path".as_ptr(),
50 signature: c"s".as_ptr(),
51 types: {
52 static TYPES: [Option<&'static wl_interface>; 1] = [None];
53 TYPES.as_ptr().cast()
54 },
55 },
56 wl_message {
57 name: c"done".as_ptr(),
58 signature: c"".as_ptr(),
59 types: {
60 static TYPES: [Option<&'static wl_interface>; 0] = [];
61 TYPES.as_ptr().cast()
62 },
63 },
64 wl_message {
65 name: c"removed".as_ptr(),
66 signature: c"".as_ptr(),
67 types: {
68 static TYPES: [Option<&'static wl_interface>; 0] = [];
69 TYPES.as_ptr().cast()
70 },
71 },
72 ];
73 MESSAGES.as_ptr()
74 },
75};
76
77#[derive(Clone, Eq, PartialEq)]
81#[repr(transparent)]
82pub struct ZwpTabletV2 {
83 proxy: UntypedOwnedProxy,
85}
86
87#[derive(Eq, PartialEq)]
91#[repr(transparent)]
92pub struct ZwpTabletV2Ref {
93 proxy: UntypedBorrowedProxy,
95}
96
97unsafe impl UntypedOwnedProxyWrapper for ZwpTabletV2 {}
99
100unsafe impl OwnedProxy for ZwpTabletV2 {
103 const INTERFACE: &'static str = "zwp_tablet_v2";
104 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
105 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
106 private::EventHandler(private::NoOpEventHandler);
107 const MAX_VERSION: u32 = 1;
108
109 type Borrowed = ZwpTabletV2Ref;
110 type Api = private::ProxyApi;
111 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
112}
113
114unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletV2Ref {}
116
117unsafe impl BorrowedProxy for ZwpTabletV2Ref {
119 type Owned = ZwpTabletV2;
120}
121
122impl Deref for ZwpTabletV2 {
123 type Target = ZwpTabletV2Ref;
124
125 fn deref(&self) -> &Self::Target {
126 proxy::low_level::deref(self)
127 }
128}
129
130mod private {
131 pub struct ProxyApi;
132
133 #[allow(dead_code)]
134 pub struct EventHandler<H>(pub(super) H);
135
136 #[allow(dead_code)]
137 pub struct NoOpEventHandler;
138}
139
140impl Debug for ZwpTabletV2 {
141 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
142 write!(f, "zwp_tablet_v2#{}", self.proxy.id())
143 }
144}
145
146impl Debug for ZwpTabletV2Ref {
147 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
148 write!(f, "zwp_tablet_v2#{}", self.proxy.id())
149 }
150}
151
152impl PartialEq<ZwpTabletV2Ref> for ZwpTabletV2 {
153 fn eq(&self, other: &ZwpTabletV2Ref) -> bool {
154 self.proxy == other.proxy
155 }
156}
157
158impl PartialEq<ZwpTabletV2> for ZwpTabletV2Ref {
159 fn eq(&self, other: &ZwpTabletV2) -> bool {
160 self.proxy == other.proxy
161 }
162}
163
164#[allow(dead_code)]
165impl ZwpTabletV2 {
166 #[allow(dead_code)]
168 pub const REQ__DESTROY__SINCE: u32 = 1;
169
170 #[inline]
174 pub fn destroy(&self) {
175 let mut args = [];
176 unsafe {
180 self.proxy.send_destructor(0, &mut args);
181 }
182 }
183}
184
185impl ZwpTabletV2 {
186 #[allow(dead_code)]
188 pub const EVT__NAME__SINCE: u32 = 1;
189
190 #[allow(dead_code)]
192 pub const EVT__ID__SINCE: u32 = 1;
193
194 #[allow(dead_code)]
196 pub const EVT__PATH__SINCE: u32 = 1;
197
198 #[allow(dead_code)]
200 pub const EVT__DONE__SINCE: u32 = 1;
201
202 #[allow(dead_code)]
204 pub const EVT__REMOVED__SINCE: u32 = 1;
205}
206
207#[allow(dead_code)]
209pub trait ZwpTabletV2EventHandler {
210 type Data: 'static;
211
212 #[inline]
225 fn name(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref, name: &str) {
226 let _ = name;
227 }
228
229 #[inline]
244 fn id(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref, vid: u32, pid: u32) {
245 let _ = vid;
246 let _ = pid;
247 }
248
249 #[inline]
270 fn path(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref, path: &str) {
271 let _ = path;
272 }
273
274 #[inline]
281 fn done(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref) {}
282
283 #[inline]
291 fn removed(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref) {}
292}
293
294impl ZwpTabletV2EventHandler for private::NoOpEventHandler {
295 type Data = ();
296}
297
298unsafe impl<H> EventHandler for private::EventHandler<H>
301where
302 H: ZwpTabletV2EventHandler,
303{
304 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
305
306 #[inline]
307 fn mutable_type() -> Option<(TypeId, &'static str)> {
308 let id = TypeId::of::<H::Data>();
309 let name = std::any::type_name::<H::Data>();
310 Some((id, name))
311 }
312
313 #[allow(unused_variables)]
314 unsafe fn handle_event(
315 &self,
316 queue: &Queue,
317 data: *mut u8,
318 slf: &UntypedBorrowedProxy,
319 opcode: u32,
320 args: *mut wl_argument,
321 ) {
322 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletV2Ref>(slf) };
324 let data: &mut H::Data = unsafe { &mut *data.cast() };
328 match opcode {
329 0 => {
330 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
332 let arg0 = unsafe { convert_string_arg("zwp_tablet_v2", "name", args[0].s) };
335 self.0.name(data, slf, arg0);
336 }
337 1 => {
338 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
340 let arg0 = unsafe { args[0].u };
342 let arg1 = unsafe { args[1].u };
344 self.0.id(data, slf, arg0, arg1);
345 }
346 2 => {
347 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
349 let arg0 = unsafe { convert_string_arg("zwp_tablet_v2", "path", args[0].s) };
352 self.0.path(data, slf, arg0);
353 }
354 3 => {
355 self.0.done(data, slf);
356 }
357 4 => {
358 self.0.removed(data, slf);
359 }
360 _ => {
361 invalid_opcode("zwp_tablet_v2", opcode);
362 }
363 }
364 }
365}
366
367impl<H> CreateEventHandler<H> for private::ProxyApi
368where
369 H: ZwpTabletV2EventHandler,
370{
371 type EventHandler = private::EventHandler<H>;
372
373 #[inline]
374 fn create_event_handler(handler: H) -> Self::EventHandler {
375 private::EventHandler(handler)
376 }
377}
378
379pub mod event_handlers {
381 use super::*;
382
383 pub struct Name<T, F>(F, PhantomData<fn(&mut T)>);
385 impl<T, F> ZwpTabletV2EventHandler for Name<T, F>
386 where
387 T: 'static,
388 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
389 {
390 type Data = T;
391
392 #[inline]
393 fn name(&self, _data: &mut T, _slf: &ZwpTabletV2Ref, name: &str) {
394 self.0(_data, _slf, name)
395 }
396 }
397
398 pub struct Id<T, F>(F, PhantomData<fn(&mut T)>);
400 impl<T, F> ZwpTabletV2EventHandler for Id<T, F>
401 where
402 T: 'static,
403 F: Fn(&mut T, &ZwpTabletV2Ref, u32, u32),
404 {
405 type Data = T;
406
407 #[inline]
408 fn id(&self, _data: &mut T, _slf: &ZwpTabletV2Ref, vid: u32, pid: u32) {
409 self.0(_data, _slf, vid, pid)
410 }
411 }
412
413 pub struct Path<T, F>(F, PhantomData<fn(&mut T)>);
415 impl<T, F> ZwpTabletV2EventHandler for Path<T, F>
416 where
417 T: 'static,
418 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
419 {
420 type Data = T;
421
422 #[inline]
423 fn path(&self, _data: &mut T, _slf: &ZwpTabletV2Ref, path: &str) {
424 self.0(_data, _slf, path)
425 }
426 }
427
428 pub struct Done<T, F>(F, PhantomData<fn(&mut T)>);
430 impl<T, F> ZwpTabletV2EventHandler for Done<T, F>
431 where
432 T: 'static,
433 F: Fn(&mut T, &ZwpTabletV2Ref),
434 {
435 type Data = T;
436
437 #[inline]
438 fn done(&self, _data: &mut T, _slf: &ZwpTabletV2Ref) {
439 self.0(_data, _slf)
440 }
441 }
442
443 pub struct Removed<T, F>(F, PhantomData<fn(&mut T)>);
445 impl<T, F> ZwpTabletV2EventHandler for Removed<T, F>
446 where
447 T: 'static,
448 F: Fn(&mut T, &ZwpTabletV2Ref),
449 {
450 type Data = T;
451
452 #[inline]
453 fn removed(&self, _data: &mut T, _slf: &ZwpTabletV2Ref) {
454 self.0(_data, _slf)
455 }
456 }
457
458 impl ZwpTabletV2 {
459 #[allow(dead_code)]
463 pub fn on_name<T, F>(f: F) -> Name<T, F>
464 where
465 T: 'static,
466 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
467 {
468 Name(f, PhantomData)
469 }
470
471 #[allow(dead_code)]
475 pub fn on_id<T, F>(f: F) -> Id<T, F>
476 where
477 T: 'static,
478 F: Fn(&mut T, &ZwpTabletV2Ref, u32, u32),
479 {
480 Id(f, PhantomData)
481 }
482
483 #[allow(dead_code)]
487 pub fn on_path<T, F>(f: F) -> Path<T, F>
488 where
489 T: 'static,
490 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
491 {
492 Path(f, PhantomData)
493 }
494
495 #[allow(dead_code)]
499 pub fn on_done<T, F>(f: F) -> Done<T, F>
500 where
501 T: 'static,
502 F: Fn(&mut T, &ZwpTabletV2Ref),
503 {
504 Done(f, PhantomData)
505 }
506
507 #[allow(dead_code)]
511 pub fn on_removed<T, F>(f: F) -> Removed<T, F>
512 where
513 T: 'static,
514 F: Fn(&mut T, &ZwpTabletV2Ref),
515 {
516 Removed(f, PhantomData)
517 }
518 }
519}