get_registry/common/protocols/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 #[inline]
200 fn tablet_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
201 let _ = id;
202 }
203
204 #[inline]
215 fn tool_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
216 let _ = id;
217 }
218
219 #[inline]
236 fn pad_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
237 let _ = id;
238 }
239}
240
241impl ZwpTabletSeatV2EventHandler for private::NoOpEventHandler {}
242
243unsafe impl<H> EventHandler for private::EventHandler<H>
245where
246 H: ZwpTabletSeatV2EventHandler,
247{
248 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
249
250 #[allow(unused_variables)]
251 unsafe fn handle_event(
252 &self,
253 queue: &Queue,
254 data: *mut u8,
255 slf: &UntypedBorrowedProxy,
256 opcode: u32,
257 args: *mut wl_argument,
258 ) {
259 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletSeatV2Ref>(slf) };
261 match opcode {
262 0 => {
263 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
265 let arg0 = unsafe {
269 UntypedOwnedProxy::from_plain_wl_proxy(
270 queue,
271 NonNull::new_unchecked(args[0].o.cast()),
272 ZwpTabletV2::WL_INTERFACE,
273 )
274 };
275 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletV2>(arg0) };
277 self.0.tablet_added(slf, arg0);
278 }
279 1 => {
280 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
282 let arg0 = unsafe {
286 UntypedOwnedProxy::from_plain_wl_proxy(
287 queue,
288 NonNull::new_unchecked(args[0].o.cast()),
289 ZwpTabletToolV2::WL_INTERFACE,
290 )
291 };
292 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletToolV2>(arg0) };
294 self.0.tool_added(slf, arg0);
295 }
296 2 => {
297 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
299 let arg0 = unsafe {
303 UntypedOwnedProxy::from_plain_wl_proxy(
304 queue,
305 NonNull::new_unchecked(args[0].o.cast()),
306 ZwpTabletPadV2::WL_INTERFACE,
307 )
308 };
309 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletPadV2>(arg0) };
311 self.0.pad_added(slf, arg0);
312 }
313 _ => {
314 invalid_opcode("zwp_tablet_seat_v2", opcode);
315 }
316 }
317 }
318}
319
320impl<H> CreateEventHandler<H> for private::ProxyApi
321where
322 H: ZwpTabletSeatV2EventHandler,
323{
324 type EventHandler = private::EventHandler<H>;
325
326 #[inline]
327 fn create_event_handler(handler: H) -> Self::EventHandler {
328 private::EventHandler(handler)
329 }
330}
331
332pub mod event_handlers {
334 use super::*;
335
336 pub struct TabletAdded<F>(F);
338 impl<F> ZwpTabletSeatV2EventHandler for TabletAdded<F>
339 where
340 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletV2),
341 {
342 #[inline]
343 fn tablet_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
344 self.0(_slf, id)
345 }
346 }
347
348 pub struct ToolAdded<F>(F);
350 impl<F> ZwpTabletSeatV2EventHandler for ToolAdded<F>
351 where
352 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletToolV2),
353 {
354 #[inline]
355 fn tool_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
356 self.0(_slf, id)
357 }
358 }
359
360 pub struct PadAdded<F>(F);
362 impl<F> ZwpTabletSeatV2EventHandler for PadAdded<F>
363 where
364 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletPadV2),
365 {
366 #[inline]
367 fn pad_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
368 self.0(_slf, id)
369 }
370 }
371
372 impl ZwpTabletSeatV2 {
373 #[allow(dead_code)]
377 pub fn on_tablet_added<F>(f: F) -> TabletAdded<F>
378 where
379 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletV2),
380 {
381 TabletAdded(f)
382 }
383
384 #[allow(dead_code)]
388 pub fn on_tool_added<F>(f: F) -> ToolAdded<F>
389 where
390 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletToolV2),
391 {
392 ToolAdded(f)
393 }
394
395 #[allow(dead_code)]
399 pub fn on_pad_added<F>(f: F) -> PadAdded<F>
400 where
401 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletPadV2),
402 {
403 PadAdded(f)
404 }
405 }
406}