poll_integration/common/protocols/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 #[inline]
196 fn tablet_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
197 let _ = id;
198 }
199
200 #[inline]
211 fn tool_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
212 let _ = id;
213 }
214
215 #[inline]
232 fn pad_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
233 let _ = id;
234 }
235}
236
237impl ZwpTabletSeatV2EventHandler for private::NoOpEventHandler {}
238
239unsafe impl<H> EventHandler for private::EventHandler<H>
241where
242 H: ZwpTabletSeatV2EventHandler,
243{
244 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
245
246 #[allow(unused_variables)]
247 unsafe fn handle_event(
248 &self,
249 queue: &Queue,
250 slf: &UntypedBorrowedProxy,
251 opcode: u32,
252 args: *mut wl_argument,
253 ) {
254 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletSeatV2Ref>(slf) };
256 match opcode {
257 0 => {
258 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
260 let arg0 = unsafe {
264 UntypedOwnedProxy::from_plain_wl_proxy(
265 queue,
266 NonNull::new_unchecked(args[0].o.cast()),
267 ZwpTabletV2::WL_INTERFACE,
268 )
269 };
270 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletV2>(arg0) };
272 self.0.tablet_added(slf, arg0);
273 }
274 1 => {
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 ZwpTabletToolV2::WL_INTERFACE,
285 )
286 };
287 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletToolV2>(arg0) };
289 self.0.tool_added(slf, arg0);
290 }
291 2 => {
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 ZwpTabletPadV2::WL_INTERFACE,
302 )
303 };
304 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletPadV2>(arg0) };
306 self.0.pad_added(slf, arg0);
307 }
308 _ => {
309 invalid_opcode("zwp_tablet_seat_v2", opcode);
310 }
311 }
312 }
313}
314
315impl<H> CreateEventHandler<H> for private::ProxyApi
316where
317 H: ZwpTabletSeatV2EventHandler,
318{
319 type EventHandler = private::EventHandler<H>;
320
321 #[inline]
322 fn create_event_handler(handler: H) -> Self::EventHandler {
323 private::EventHandler(handler)
324 }
325}
326
327pub mod event_handlers {
329 use super::*;
330
331 pub struct TabletAdded<F>(F);
333 impl<F> ZwpTabletSeatV2EventHandler for TabletAdded<F>
334 where
335 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletV2),
336 {
337 #[inline]
338 fn tablet_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
339 self.0(_slf, id)
340 }
341 }
342
343 pub struct ToolAdded<F>(F);
345 impl<F> ZwpTabletSeatV2EventHandler for ToolAdded<F>
346 where
347 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletToolV2),
348 {
349 #[inline]
350 fn tool_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
351 self.0(_slf, id)
352 }
353 }
354
355 pub struct PadAdded<F>(F);
357 impl<F> ZwpTabletSeatV2EventHandler for PadAdded<F>
358 where
359 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletPadV2),
360 {
361 #[inline]
362 fn pad_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
363 self.0(_slf, id)
364 }
365 }
366
367 impl ZwpTabletSeatV2 {
368 #[allow(dead_code)]
372 pub fn on_tablet_added<F>(f: F) -> TabletAdded<F>
373 where
374 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletV2),
375 {
376 TabletAdded(f)
377 }
378
379 #[allow(dead_code)]
383 pub fn on_tool_added<F>(f: F) -> ToolAdded<F>
384 where
385 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletToolV2),
386 {
387 ToolAdded(f)
388 }
389
390 #[allow(dead_code)]
394 pub fn on_pad_added<F>(f: F) -> PadAdded<F>
395 where
396 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletPadV2),
397 {
398 PadAdded(f)
399 }
400 }
401}