simple_window/common/protocols_data/tablet_v2/
zwp_tablet_seat_v2.rs1use {super::super::all_types::*, ::wl_client::builder::prelude::*};
8
9static INTERFACE: wl_interface = wl_interface {
10 name: c"zwp_tablet_seat_v2".as_ptr(),
11 version: 1,
12 method_count: 1,
13 methods: {
14 static MESSAGES: [wl_message; 1] = [wl_message {
15 name: c"destroy".as_ptr(),
16 signature: c"".as_ptr(),
17 types: {
18 static TYPES: [Option<&'static wl_interface>; 0] = [];
19 TYPES.as_ptr().cast()
20 },
21 }];
22 MESSAGES.as_ptr()
23 },
24 event_count: 3,
25 events: {
26 static MESSAGES: [wl_message; 3] = [
27 wl_message {
28 name: c"tablet_added".as_ptr(),
29 signature: c"n".as_ptr(),
30 types: {
31 static TYPES: [Option<&'static wl_interface>; 1] =
32 [Some(ZwpTabletV2::WL_INTERFACE)];
33 TYPES.as_ptr().cast()
34 },
35 },
36 wl_message {
37 name: c"tool_added".as_ptr(),
38 signature: c"n".as_ptr(),
39 types: {
40 static TYPES: [Option<&'static wl_interface>; 1] =
41 [Some(ZwpTabletToolV2::WL_INTERFACE)];
42 TYPES.as_ptr().cast()
43 },
44 },
45 wl_message {
46 name: c"pad_added".as_ptr(),
47 signature: c"n".as_ptr(),
48 types: {
49 static TYPES: [Option<&'static wl_interface>; 1] =
50 [Some(ZwpTabletPadV2::WL_INTERFACE)];
51 TYPES.as_ptr().cast()
52 },
53 },
54 ];
55 MESSAGES.as_ptr()
56 },
57};
58
59#[derive(Clone, Eq, PartialEq)]
63#[repr(transparent)]
64pub struct ZwpTabletSeatV2 {
65 proxy: UntypedOwnedProxy,
67}
68
69#[derive(Eq, PartialEq)]
73#[repr(transparent)]
74pub struct ZwpTabletSeatV2Ref {
75 proxy: UntypedBorrowedProxy,
77}
78
79unsafe impl UntypedOwnedProxyWrapper for ZwpTabletSeatV2 {}
81
82unsafe impl OwnedProxy for ZwpTabletSeatV2 {
85 const INTERFACE: &'static str = "zwp_tablet_seat_v2";
86 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
87 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
88 private::EventHandler(private::NoOpEventHandler);
89 const MAX_VERSION: u32 = 1;
90
91 type Borrowed = ZwpTabletSeatV2Ref;
92 type Api = private::ProxyApi;
93 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
94}
95
96unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletSeatV2Ref {}
98
99unsafe impl BorrowedProxy for ZwpTabletSeatV2Ref {
101 type Owned = ZwpTabletSeatV2;
102}
103
104impl Deref for ZwpTabletSeatV2 {
105 type Target = ZwpTabletSeatV2Ref;
106
107 fn deref(&self) -> &Self::Target {
108 proxy::low_level::deref(self)
109 }
110}
111
112mod private {
113 pub struct ProxyApi;
114
115 #[allow(dead_code)]
116 pub struct EventHandler<H>(pub(super) H);
117
118 #[allow(dead_code)]
119 pub struct NoOpEventHandler;
120}
121
122impl Debug for ZwpTabletSeatV2 {
123 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
124 write!(f, "zwp_tablet_seat_v2#{}", self.proxy.id())
125 }
126}
127
128impl Debug for ZwpTabletSeatV2Ref {
129 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
130 write!(f, "zwp_tablet_seat_v2#{}", self.proxy.id())
131 }
132}
133
134impl PartialEq<ZwpTabletSeatV2Ref> for ZwpTabletSeatV2 {
135 fn eq(&self, other: &ZwpTabletSeatV2Ref) -> bool {
136 self.proxy == other.proxy
137 }
138}
139
140impl PartialEq<ZwpTabletSeatV2> for ZwpTabletSeatV2Ref {
141 fn eq(&self, other: &ZwpTabletSeatV2) -> bool {
142 self.proxy == other.proxy
143 }
144}
145
146#[allow(dead_code)]
147impl ZwpTabletSeatV2 {
148 #[allow(dead_code)]
150 pub const REQ__DESTROY__SINCE: u32 = 1;
151
152 #[inline]
157 pub fn destroy(&self) {
158 let mut args = [];
159 unsafe {
163 self.proxy.send_destructor(0, &mut args);
164 }
165 }
166}
167
168impl ZwpTabletSeatV2 {
169 #[allow(dead_code)]
171 pub const EVT__TABLET_ADDED__SINCE: u32 = 1;
172
173 #[allow(dead_code)]
175 pub const EVT__TOOL_ADDED__SINCE: u32 = 1;
176
177 #[allow(dead_code)]
179 pub const EVT__PAD_ADDED__SINCE: u32 = 1;
180}
181
182#[allow(dead_code)]
184pub trait ZwpTabletSeatV2EventHandler {
185 type Data: 'static;
186
187 #[inline]
198 fn tablet_added(&self, _data: &mut Self::Data, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
199 let _ = id;
200 }
201
202 #[inline]
213 fn tool_added(&self, _data: &mut Self::Data, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
214 let _ = id;
215 }
216
217 #[inline]
234 fn pad_added(&self, _data: &mut Self::Data, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
235 let _ = id;
236 }
237}
238
239impl ZwpTabletSeatV2EventHandler for private::NoOpEventHandler {
240 type Data = ();
241}
242
243unsafe impl<H> EventHandler for private::EventHandler<H>
246where
247 H: ZwpTabletSeatV2EventHandler,
248{
249 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
250
251 #[inline]
252 fn mutable_type() -> Option<(TypeId, &'static str)> {
253 let id = TypeId::of::<H::Data>();
254 let name = std::any::type_name::<H::Data>();
255 Some((id, name))
256 }
257
258 #[allow(unused_variables)]
259 unsafe fn handle_event(
260 &self,
261 queue: &Queue,
262 data: *mut u8,
263 slf: &UntypedBorrowedProxy,
264 opcode: u32,
265 args: *mut wl_argument,
266 ) {
267 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletSeatV2Ref>(slf) };
269 let data: &mut H::Data = unsafe { &mut *data.cast() };
273 match opcode {
274 0 => {
275 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
277 let arg0 = unsafe {
281 UntypedOwnedProxy::from_plain_wl_proxy(
282 queue,
283 NonNull::new_unchecked(args[0].o.cast()),
284 ZwpTabletV2::WL_INTERFACE,
285 )
286 };
287 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletV2>(arg0) };
289 self.0.tablet_added(data, slf, arg0);
290 }
291 1 => {
292 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
294 let arg0 = unsafe {
298 UntypedOwnedProxy::from_plain_wl_proxy(
299 queue,
300 NonNull::new_unchecked(args[0].o.cast()),
301 ZwpTabletToolV2::WL_INTERFACE,
302 )
303 };
304 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletToolV2>(arg0) };
306 self.0.tool_added(data, slf, arg0);
307 }
308 2 => {
309 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
311 let arg0 = unsafe {
315 UntypedOwnedProxy::from_plain_wl_proxy(
316 queue,
317 NonNull::new_unchecked(args[0].o.cast()),
318 ZwpTabletPadV2::WL_INTERFACE,
319 )
320 };
321 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletPadV2>(arg0) };
323 self.0.pad_added(data, slf, arg0);
324 }
325 _ => {
326 invalid_opcode("zwp_tablet_seat_v2", opcode);
327 }
328 }
329 }
330}
331
332impl<H> CreateEventHandler<H> for private::ProxyApi
333where
334 H: ZwpTabletSeatV2EventHandler,
335{
336 type EventHandler = private::EventHandler<H>;
337
338 #[inline]
339 fn create_event_handler(handler: H) -> Self::EventHandler {
340 private::EventHandler(handler)
341 }
342}
343
344pub mod event_handlers {
346 use super::*;
347
348 pub struct TabletAdded<T, F>(F, PhantomData<fn(&mut T)>);
350 impl<T, F> ZwpTabletSeatV2EventHandler for TabletAdded<T, F>
351 where
352 T: 'static,
353 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletV2),
354 {
355 type Data = T;
356
357 #[inline]
358 fn tablet_added(&self, _data: &mut T, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
359 self.0(_data, _slf, id)
360 }
361 }
362
363 pub struct ToolAdded<T, F>(F, PhantomData<fn(&mut T)>);
365 impl<T, F> ZwpTabletSeatV2EventHandler for ToolAdded<T, F>
366 where
367 T: 'static,
368 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletToolV2),
369 {
370 type Data = T;
371
372 #[inline]
373 fn tool_added(&self, _data: &mut T, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
374 self.0(_data, _slf, id)
375 }
376 }
377
378 pub struct PadAdded<T, F>(F, PhantomData<fn(&mut T)>);
380 impl<T, F> ZwpTabletSeatV2EventHandler for PadAdded<T, F>
381 where
382 T: 'static,
383 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletPadV2),
384 {
385 type Data = T;
386
387 #[inline]
388 fn pad_added(&self, _data: &mut T, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
389 self.0(_data, _slf, id)
390 }
391 }
392
393 impl ZwpTabletSeatV2 {
394 #[allow(dead_code)]
398 pub fn on_tablet_added<T, F>(f: F) -> TabletAdded<T, F>
399 where
400 T: 'static,
401 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletV2),
402 {
403 TabletAdded(f, PhantomData)
404 }
405
406 #[allow(dead_code)]
410 pub fn on_tool_added<T, F>(f: F) -> ToolAdded<T, F>
411 where
412 T: 'static,
413 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletToolV2),
414 {
415 ToolAdded(f, PhantomData)
416 }
417
418 #[allow(dead_code)]
422 pub fn on_pad_added<T, F>(f: F) -> PadAdded<T, F>
423 where
424 T: 'static,
425 F: Fn(&mut T, &ZwpTabletSeatV2Ref, ZwpTabletPadV2),
426 {
427 PadAdded(f, PhantomData)
428 }
429 }
430}