1use super::super::all_types::*;
13use ::wl_client::builder::prelude::*;
14
15static INTERFACE: wl_interface = wl_interface {
16 name: c"zwp_tablet_v2".as_ptr(),
17 version: 1,
18 method_count: 1,
19 methods: {
20 static MESSAGES: [wl_message; 1] = [wl_message {
21 name: c"destroy".as_ptr(),
22 signature: c"".as_ptr(),
23 types: {
24 static TYPES: [Option<&'static wl_interface>; 0] = [];
25 TYPES.as_ptr().cast()
26 },
27 }];
28 MESSAGES.as_ptr()
29 },
30 event_count: 5,
31 events: {
32 static MESSAGES: [wl_message; 5] = [
33 wl_message {
34 name: c"name".as_ptr(),
35 signature: c"s".as_ptr(),
36 types: {
37 static TYPES: [Option<&'static wl_interface>; 1] = [None];
38 TYPES.as_ptr().cast()
39 },
40 },
41 wl_message {
42 name: c"id".as_ptr(),
43 signature: c"uu".as_ptr(),
44 types: {
45 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
46 TYPES.as_ptr().cast()
47 },
48 },
49 wl_message {
50 name: c"path".as_ptr(),
51 signature: c"s".as_ptr(),
52 types: {
53 static TYPES: [Option<&'static wl_interface>; 1] = [None];
54 TYPES.as_ptr().cast()
55 },
56 },
57 wl_message {
58 name: c"done".as_ptr(),
59 signature: c"".as_ptr(),
60 types: {
61 static TYPES: [Option<&'static wl_interface>; 0] = [];
62 TYPES.as_ptr().cast()
63 },
64 },
65 wl_message {
66 name: c"removed".as_ptr(),
67 signature: c"".as_ptr(),
68 types: {
69 static TYPES: [Option<&'static wl_interface>; 0] = [];
70 TYPES.as_ptr().cast()
71 },
72 },
73 ];
74 MESSAGES.as_ptr()
75 },
76};
77
78#[derive(Clone, Eq, PartialEq)]
82#[repr(transparent)]
83pub struct ZwpTabletV2 {
84 proxy: UntypedOwnedProxy,
86}
87
88#[derive(Eq, PartialEq)]
92#[repr(transparent)]
93pub struct ZwpTabletV2Ref {
94 proxy: UntypedBorrowedProxy,
96}
97
98unsafe impl UntypedOwnedProxyWrapper for ZwpTabletV2 {}
100
101unsafe impl OwnedProxy for ZwpTabletV2 {
104 const INTERFACE: &'static str = "zwp_tablet_v2";
105 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
106 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
107 private::EventHandler(private::NoOpEventHandler);
108 const MAX_VERSION: u32 = 1;
109
110 type Borrowed = ZwpTabletV2Ref;
111 type Api = private::ProxyApi;
112 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
113}
114
115unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletV2Ref {}
117
118unsafe impl BorrowedProxy for ZwpTabletV2Ref {
120 type Owned = ZwpTabletV2;
121}
122
123impl Deref for ZwpTabletV2 {
124 type Target = ZwpTabletV2Ref;
125
126 fn deref(&self) -> &Self::Target {
127 proxy::low_level::deref(self)
128 }
129}
130
131mod private {
132 pub struct ProxyApi;
133
134 #[allow(dead_code)]
135 pub struct EventHandler<H>(pub(super) H);
136
137 #[allow(dead_code)]
138 pub struct NoOpEventHandler;
139}
140
141impl Debug for ZwpTabletV2 {
142 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
143 write!(f, "zwp_tablet_v2#{}", self.proxy.id())
144 }
145}
146
147impl Debug for ZwpTabletV2Ref {
148 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
149 write!(f, "zwp_tablet_v2#{}", self.proxy.id())
150 }
151}
152
153impl PartialEq<ZwpTabletV2Ref> for ZwpTabletV2 {
154 fn eq(&self, other: &ZwpTabletV2Ref) -> bool {
155 self.proxy == other.proxy
156 }
157}
158
159impl PartialEq<ZwpTabletV2> for ZwpTabletV2Ref {
160 fn eq(&self, other: &ZwpTabletV2) -> bool {
161 self.proxy == other.proxy
162 }
163}
164
165#[allow(dead_code)]
166impl ZwpTabletV2 {
167 #[allow(dead_code)]
169 pub const REQ__DESTROY__SINCE: u32 = 1;
170}
171
172#[allow(dead_code)]
173impl ZwpTabletV2 {
174 #[inline]
178 pub fn destroy(&self) {
179 let mut args = [];
180 unsafe {
184 self.proxy.send_destructor(0, &mut args);
185 }
186 }
187}
188
189impl ZwpTabletV2 {
190 #[allow(dead_code)]
192 pub const EVT__NAME__SINCE: u32 = 1;
193
194 #[allow(dead_code)]
196 pub const EVT__ID__SINCE: u32 = 1;
197
198 #[allow(dead_code)]
200 pub const EVT__PATH__SINCE: u32 = 1;
201
202 #[allow(dead_code)]
204 pub const EVT__DONE__SINCE: u32 = 1;
205
206 #[allow(dead_code)]
208 pub const EVT__REMOVED__SINCE: u32 = 1;
209}
210
211#[allow(dead_code)]
213pub trait ZwpTabletV2EventHandler {
214 type Data: 'static;
215
216 #[inline]
229 fn name(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref, name: &str) {
230 let _ = name;
231 }
232
233 #[inline]
248 fn id(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref, vid: u32, pid: u32) {
249 let _ = vid;
250 let _ = pid;
251 }
252
253 #[inline]
274 fn path(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref, path: &str) {
275 let _ = path;
276 }
277
278 #[inline]
285 fn done(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref) {}
286
287 #[inline]
295 fn removed(&self, _data: &mut Self::Data, _slf: &ZwpTabletV2Ref) {}
296}
297
298impl ZwpTabletV2EventHandler for private::NoOpEventHandler {
299 type Data = ();
300}
301
302unsafe impl<H> EventHandler for private::EventHandler<H>
305where
306 H: ZwpTabletV2EventHandler,
307{
308 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
309
310 #[inline]
311 fn mutable_type() -> Option<(TypeId, &'static str)> {
312 let id = TypeId::of::<H::Data>();
313 let name = std::any::type_name::<H::Data>();
314 Some((id, name))
315 }
316
317 #[allow(unused_variables)]
318 unsafe fn handle_event(
319 &self,
320 queue: &Queue,
321 data: *mut u8,
322 slf: &UntypedBorrowedProxy,
323 opcode: u32,
324 args: *mut wl_argument,
325 ) {
326 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletV2Ref>(slf) };
328 let data: &mut H::Data = unsafe { &mut *data.cast() };
332 match opcode {
333 0 => {
334 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
336 let arg0 = unsafe { convert_string_arg("zwp_tablet_v2", "name", args[0].s) };
339 self.0.name(data, slf, arg0);
340 }
341 1 => {
342 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
344 let arg0 = unsafe { args[0].u };
346 let arg1 = unsafe { args[1].u };
348 self.0.id(data, slf, arg0, arg1);
349 }
350 2 => {
351 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
353 let arg0 = unsafe { convert_string_arg("zwp_tablet_v2", "path", args[0].s) };
356 self.0.path(data, slf, arg0);
357 }
358 3 => {
359 self.0.done(data, slf);
360 }
361 4 => {
362 self.0.removed(data, slf);
363 }
364 _ => {
365 invalid_opcode("zwp_tablet_v2", opcode);
366 }
367 }
368 }
369}
370
371impl<H> CreateEventHandler<H> for private::ProxyApi
372where
373 H: ZwpTabletV2EventHandler,
374{
375 type EventHandler = private::EventHandler<H>;
376
377 #[inline]
378 fn create_event_handler(handler: H) -> Self::EventHandler {
379 private::EventHandler(handler)
380 }
381}
382
383pub mod event_handlers {
385 use super::*;
386
387 pub struct Name<T, F>(F, PhantomData<fn(&mut T)>);
389 impl<T, F> ZwpTabletV2EventHandler for Name<T, F>
390 where
391 T: 'static,
392 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
393 {
394 type Data = T;
395
396 #[inline]
397 fn name(&self, _data: &mut T, _slf: &ZwpTabletV2Ref, name: &str) {
398 self.0(_data, _slf, name)
399 }
400 }
401
402 pub struct Id<T, F>(F, PhantomData<fn(&mut T)>);
404 impl<T, F> ZwpTabletV2EventHandler for Id<T, F>
405 where
406 T: 'static,
407 F: Fn(&mut T, &ZwpTabletV2Ref, u32, u32),
408 {
409 type Data = T;
410
411 #[inline]
412 fn id(&self, _data: &mut T, _slf: &ZwpTabletV2Ref, vid: u32, pid: u32) {
413 self.0(_data, _slf, vid, pid)
414 }
415 }
416
417 pub struct Path<T, F>(F, PhantomData<fn(&mut T)>);
419 impl<T, F> ZwpTabletV2EventHandler for Path<T, F>
420 where
421 T: 'static,
422 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
423 {
424 type Data = T;
425
426 #[inline]
427 fn path(&self, _data: &mut T, _slf: &ZwpTabletV2Ref, path: &str) {
428 self.0(_data, _slf, path)
429 }
430 }
431
432 pub struct Done<T, F>(F, PhantomData<fn(&mut T)>);
434 impl<T, F> ZwpTabletV2EventHandler for Done<T, F>
435 where
436 T: 'static,
437 F: Fn(&mut T, &ZwpTabletV2Ref),
438 {
439 type Data = T;
440
441 #[inline]
442 fn done(&self, _data: &mut T, _slf: &ZwpTabletV2Ref) {
443 self.0(_data, _slf)
444 }
445 }
446
447 pub struct Removed<T, F>(F, PhantomData<fn(&mut T)>);
449 impl<T, F> ZwpTabletV2EventHandler for Removed<T, F>
450 where
451 T: 'static,
452 F: Fn(&mut T, &ZwpTabletV2Ref),
453 {
454 type Data = T;
455
456 #[inline]
457 fn removed(&self, _data: &mut T, _slf: &ZwpTabletV2Ref) {
458 self.0(_data, _slf)
459 }
460 }
461
462 impl ZwpTabletV2 {
463 #[allow(dead_code)]
467 pub fn on_name<T, F>(f: F) -> Name<T, F>
468 where
469 T: 'static,
470 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
471 {
472 Name(f, PhantomData)
473 }
474
475 #[allow(dead_code)]
479 pub fn on_id<T, F>(f: F) -> Id<T, F>
480 where
481 T: 'static,
482 F: Fn(&mut T, &ZwpTabletV2Ref, u32, u32),
483 {
484 Id(f, PhantomData)
485 }
486
487 #[allow(dead_code)]
491 pub fn on_path<T, F>(f: F) -> Path<T, F>
492 where
493 T: 'static,
494 F: Fn(&mut T, &ZwpTabletV2Ref, &str),
495 {
496 Path(f, PhantomData)
497 }
498
499 #[allow(dead_code)]
503 pub fn on_done<T, F>(f: F) -> Done<T, F>
504 where
505 T: 'static,
506 F: Fn(&mut T, &ZwpTabletV2Ref),
507 {
508 Done(f, PhantomData)
509 }
510
511 #[allow(dead_code)]
515 pub fn on_removed<T, F>(f: F) -> Removed<T, F>
516 where
517 T: 'static,
518 F: Fn(&mut T, &ZwpTabletV2Ref),
519 {
520 Removed(f, PhantomData)
521 }
522 }
523}