simple_window/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 data: *mut u8,
251 slf: &UntypedBorrowedProxy,
252 opcode: u32,
253 args: *mut wl_argument,
254 ) {
255 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletSeatV2Ref>(slf) };
257 match opcode {
258 0 => {
259 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
261 let arg0 = unsafe {
265 UntypedOwnedProxy::from_plain_wl_proxy(
266 queue,
267 NonNull::new_unchecked(args[0].o.cast()),
268 ZwpTabletV2::WL_INTERFACE,
269 )
270 };
271 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletV2>(arg0) };
273 self.0.tablet_added(slf, arg0);
274 }
275 1 => {
276 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
278 let arg0 = unsafe {
282 UntypedOwnedProxy::from_plain_wl_proxy(
283 queue,
284 NonNull::new_unchecked(args[0].o.cast()),
285 ZwpTabletToolV2::WL_INTERFACE,
286 )
287 };
288 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletToolV2>(arg0) };
290 self.0.tool_added(slf, arg0);
291 }
292 2 => {
293 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
295 let arg0 = unsafe {
299 UntypedOwnedProxy::from_plain_wl_proxy(
300 queue,
301 NonNull::new_unchecked(args[0].o.cast()),
302 ZwpTabletPadV2::WL_INTERFACE,
303 )
304 };
305 let arg0 = unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletPadV2>(arg0) };
307 self.0.pad_added(slf, arg0);
308 }
309 _ => {
310 invalid_opcode("zwp_tablet_seat_v2", opcode);
311 }
312 }
313 }
314}
315
316impl<H> CreateEventHandler<H> for private::ProxyApi
317where
318 H: ZwpTabletSeatV2EventHandler,
319{
320 type EventHandler = private::EventHandler<H>;
321
322 #[inline]
323 fn create_event_handler(handler: H) -> Self::EventHandler {
324 private::EventHandler(handler)
325 }
326}
327
328pub mod event_handlers {
330 use super::*;
331
332 pub struct TabletAdded<F>(F);
334 impl<F> ZwpTabletSeatV2EventHandler for TabletAdded<F>
335 where
336 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletV2),
337 {
338 #[inline]
339 fn tablet_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletV2) {
340 self.0(_slf, id)
341 }
342 }
343
344 pub struct ToolAdded<F>(F);
346 impl<F> ZwpTabletSeatV2EventHandler for ToolAdded<F>
347 where
348 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletToolV2),
349 {
350 #[inline]
351 fn tool_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletToolV2) {
352 self.0(_slf, id)
353 }
354 }
355
356 pub struct PadAdded<F>(F);
358 impl<F> ZwpTabletSeatV2EventHandler for PadAdded<F>
359 where
360 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletPadV2),
361 {
362 #[inline]
363 fn pad_added(&self, _slf: &ZwpTabletSeatV2Ref, id: ZwpTabletPadV2) {
364 self.0(_slf, id)
365 }
366 }
367
368 impl ZwpTabletSeatV2 {
369 #[allow(dead_code)]
373 pub fn on_tablet_added<F>(f: F) -> TabletAdded<F>
374 where
375 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletV2),
376 {
377 TabletAdded(f)
378 }
379
380 #[allow(dead_code)]
384 pub fn on_tool_added<F>(f: F) -> ToolAdded<F>
385 where
386 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletToolV2),
387 {
388 ToolAdded(f)
389 }
390
391 #[allow(dead_code)]
395 pub fn on_pad_added<F>(f: F) -> PadAdded<F>
396 where
397 F: Fn(&ZwpTabletSeatV2Ref, ZwpTabletPadV2),
398 {
399 PadAdded(f)
400 }
401 }
402}