get_registry/common/protocols_data/tablet_v2/
zwp_tablet_seat_v2.rs1use super::super::all_types::*;
8use ::wl_client::builder::prelude::*;
9
10static INTERFACE: wl_interface = wl_interface {
11 name: c"zwp_tablet_seat_v2".as_ptr(),
12 version: 1,
13 method_count: 1,
14 methods: {
15 static MESSAGES: [wl_message; 1] = [wl_message {
16 name: c"destroy".as_ptr(),
17 signature: c"".as_ptr(),
18 types: {
19 static TYPES: [Option<&'static wl_interface>; 0] = [];
20 TYPES.as_ptr().cast()
21 },
22 }];
23 MESSAGES.as_ptr()
24 },
25 event_count: 3,
26 events: {
27 static MESSAGES: [wl_message; 3] = [
28 wl_message {
29 name: c"tablet_added".as_ptr(),
30 signature: c"n".as_ptr(),
31 types: {
32 static TYPES: [Option<&'static wl_interface>; 1] =
33 [Some(ZwpTabletV2::WL_INTERFACE)];
34 TYPES.as_ptr().cast()
35 },
36 },
37 wl_message {
38 name: c"tool_added".as_ptr(),
39 signature: c"n".as_ptr(),
40 types: {
41 static TYPES: [Option<&'static wl_interface>; 1] =
42 [Some(ZwpTabletToolV2::WL_INTERFACE)];
43 TYPES.as_ptr().cast()
44 },
45 },
46 wl_message {
47 name: c"pad_added".as_ptr(),
48 signature: c"n".as_ptr(),
49 types: {
50 static TYPES: [Option<&'static wl_interface>; 1] =
51 [Some(ZwpTabletPadV2::WL_INTERFACE)];
52 TYPES.as_ptr().cast()
53 },
54 },
55 ];
56 MESSAGES.as_ptr()
57 },
58};
59
60#[derive(Clone, Eq, PartialEq)]
64#[repr(transparent)]
65pub struct ZwpTabletSeatV2 {
66 proxy: UntypedOwnedProxy,
68}
69
70#[derive(Eq, PartialEq)]
74#[repr(transparent)]
75pub struct ZwpTabletSeatV2Ref {
76 proxy: UntypedBorrowedProxy,
78}
79
80unsafe impl UntypedOwnedProxyWrapper for ZwpTabletSeatV2 {}
82
83unsafe impl OwnedProxy for ZwpTabletSeatV2 {
86 const INTERFACE: &'static str = "zwp_tablet_seat_v2";
87 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
88 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
89 private::EventHandler(private::NoOpEventHandler);
90 const MAX_VERSION: u32 = 1;
91
92 type Borrowed = ZwpTabletSeatV2Ref;
93 type Api = private::ProxyApi;
94 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
95}
96
97unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletSeatV2Ref {}
99
100unsafe impl BorrowedProxy for ZwpTabletSeatV2Ref {
102 type Owned = ZwpTabletSeatV2;
103}
104
105impl Deref for ZwpTabletSeatV2 {
106 type Target = ZwpTabletSeatV2Ref;
107
108 fn deref(&self) -> &Self::Target {
109 proxy::low_level::deref(self)
110 }
111}
112
113mod private {
114 pub struct ProxyApi;
115
116 #[allow(dead_code)]
117 pub struct EventHandler<H>(pub(super) H);
118
119 #[allow(dead_code)]
120 pub struct NoOpEventHandler;
121}
122
123impl Debug for ZwpTabletSeatV2 {
124 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
125 write!(f, "zwp_tablet_seat_v2#{}", self.proxy.id())
126 }
127}
128
129impl Debug for ZwpTabletSeatV2Ref {
130 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
131 write!(f, "zwp_tablet_seat_v2#{}", self.proxy.id())
132 }
133}
134
135impl PartialEq<ZwpTabletSeatV2Ref> for ZwpTabletSeatV2 {
136 fn eq(&self, other: &ZwpTabletSeatV2Ref) -> bool {
137 self.proxy == other.proxy
138 }
139}
140
141impl PartialEq<ZwpTabletSeatV2> for ZwpTabletSeatV2Ref {
142 fn eq(&self, other: &ZwpTabletSeatV2) -> bool {
143 self.proxy == other.proxy
144 }
145}
146
147#[allow(dead_code)]
148impl ZwpTabletSeatV2 {
149 #[allow(dead_code)]
151 pub const REQ__DESTROY__SINCE: u32 = 1;
152}
153
154#[allow(dead_code)]
155impl ZwpTabletSeatV2 {
156 #[inline]
161 pub fn destroy(&self) {
162 let mut args = [];
163 unsafe {
167 self.proxy.send_destructor(0, &mut args);
168 }
169 }
170}
171
172impl ZwpTabletSeatV2 {
173 #[allow(dead_code)]
175 pub const EVT__TABLET_ADDED__SINCE: u32 = 1;
176
177 #[allow(dead_code)]
179 pub const EVT__TOOL_ADDED__SINCE: u32 = 1;
180
181 #[allow(dead_code)]
183 pub const EVT__PAD_ADDED__SINCE: u32 = 1;
184}
185
186#[allow(dead_code)]
188pub trait ZwpTabletSeatV2EventHandler {
189 type Data: 'static;
190
191 #[inline]
202 fn tablet_added(&self, _data: &mut Self::Data, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
203 let _ = id;
204 }
205
206 #[inline]
217 fn tool_added(&self, _data: &mut Self::Data, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
218 let _ = id;
219 }
220
221 #[inline]
238 fn pad_added(&self, _data: &mut Self::Data, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
239 let _ = id;
240 }
241}
242
243impl ZwpTabletSeatV2EventHandler for private::NoOpEventHandler {
244 type Data = ();
245}
246
247unsafe impl<H> EventHandler for private::EventHandler<H>
250where
251 H: ZwpTabletSeatV2EventHandler,
252{
253 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
254
255 #[inline]
256 fn mutable_type() -> Option<(TypeId, &'static str)> {
257 let id = TypeId::of::<H::Data>();
258 let name = std::any::type_name::<H::Data>();
259 Some((id, name))
260 }
261
262 #[allow(unused_variables)]
263 unsafe fn handle_event(
264 &self,
265 queue: &Queue,
266 data: *mut u8,
267 slf: &UntypedBorrowedProxy,
268 opcode: u32,
269 args: *mut wl_argument,
270 ) {
271 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletSeatV2Ref>(slf) };
273 let data: &mut H::Data = unsafe { &mut *data.cast() };
277 match opcode {
278 0 => {
279 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
281 let arg0 = unsafe {
285 UntypedOwnedProxy::from_plain_wl_proxy(
286 queue,
287 NonNull::new_unchecked(args[0].o.cast()),
288 ZwpTabletV2::WL_INTERFACE,
289 )
290 };
291 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletV2>(arg0) };
293 self.0.tablet_added(data, slf, arg0);
294 }
295 1 => {
296 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
298 let arg0 = unsafe {
302 UntypedOwnedProxy::from_plain_wl_proxy(
303 queue,
304 NonNull::new_unchecked(args[0].o.cast()),
305 ZwpTabletToolV2::WL_INTERFACE,
306 )
307 };
308 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletToolV2>(arg0) };
310 self.0.tool_added(data, slf, arg0);
311 }
312 2 => {
313 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
315 let arg0 = unsafe {
319 UntypedOwnedProxy::from_plain_wl_proxy(
320 queue,
321 NonNull::new_unchecked(args[0].o.cast()),
322 ZwpTabletPadV2::WL_INTERFACE,
323 )
324 };
325 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletPadV2>(arg0) };
327 self.0.pad_added(data, slf, arg0);
328 }
329 _ => {
330 invalid_opcode("zwp_tablet_seat_v2", opcode);
331 }
332 }
333 }
334}
335
336impl<H> CreateEventHandler<H> for private::ProxyApi
337where
338 H: ZwpTabletSeatV2EventHandler,
339{
340 type EventHandler = private::EventHandler<H>;
341
342 #[inline]
343 fn create_event_handler(handler: H) -> Self::EventHandler {
344 private::EventHandler(handler)
345 }
346}
347
348pub mod event_handlers {
350 use super::*;
351
352 pub struct TabletAdded<T, F>(F, PhantomData<fn(&mut T)>);
354 impl<T, F> ZwpTabletSeatV2EventHandler for TabletAdded<T, F>
355 where
356 T: 'static,
357 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletV2),
358 {
359 type Data = T;
360
361 #[inline]
362 fn tablet_added(&self, _data: &mut T, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
363 self.0(_data, _slf, id)
364 }
365 }
366
367 pub struct ToolAdded<T, F>(F, PhantomData<fn(&mut T)>);
369 impl<T, F> ZwpTabletSeatV2EventHandler for ToolAdded<T, F>
370 where
371 T: 'static,
372 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletToolV2),
373 {
374 type Data = T;
375
376 #[inline]
377 fn tool_added(&self, _data: &mut T, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
378 self.0(_data, _slf, id)
379 }
380 }
381
382 pub struct PadAdded<T, F>(F, PhantomData<fn(&mut T)>);
384 impl<T, F> ZwpTabletSeatV2EventHandler for PadAdded<T, F>
385 where
386 T: 'static,
387 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletPadV2),
388 {
389 type Data = T;
390
391 #[inline]
392 fn pad_added(&self, _data: &mut T, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
393 self.0(_data, _slf, id)
394 }
395 }
396
397 impl ZwpTabletSeatV2 {
398 #[allow(dead_code)]
402 pub fn on_tablet_added<T, F>(f: F) -> TabletAdded<T, F>
403 where
404 T: 'static,
405 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletV2),
406 {
407 TabletAdded(f, PhantomData)
408 }
409
410 #[allow(dead_code)]
414 pub fn on_tool_added<T, F>(f: F) -> ToolAdded<T, F>
415 where
416 T: 'static,
417 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletToolV2),
418 {
419 ToolAdded(f, PhantomData)
420 }
421
422 #[allow(dead_code)]
426 pub fn on_pad_added<T, F>(f: F) -> PadAdded<T, F>
427 where
428 T: 'static,
429 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletPadV2),
430 {
431 PadAdded(f, PhantomData)
432 }
433 }
434}