get_registry/common/protocols/tablet_v2/zwp_tablet_tool_v2.rs
1//! a physical tablet tool
2//!
3//! An object that represents a physical tool that has been, or is
4//! currently in use with a tablet in this seat. Each wp_tablet_tool
5//! object stays valid until the client destroys it; the compositor
6//! reuses the wp_tablet_tool object to indicate that the object's
7//! respective physical tool has come into proximity of a tablet again.
8//!
9//! A wp_tablet_tool object's relation to a physical tool depends on the
10//! tablet's ability to report serial numbers. If the tablet supports
11//! this capability, then the object represents a specific physical tool
12//! and can be identified even when used on multiple tablets.
13//!
14//! A tablet tool has a number of static characteristics, e.g. tool type,
15//! hardware_serial and capabilities. These capabilities are sent in an
16//! event sequence after the wp_tablet_seat.tool_added event before any
17//! actual events from this tool. This initial event sequence is
18//! terminated by a wp_tablet_tool.done event.
19//!
20//! Tablet tool events are grouped by wp_tablet_tool.frame events.
21//! Any events received before a wp_tablet_tool.frame event should be
22//! considered part of the same hardware state change.
23
24use super::super::all_types::*;
25use ::wl_client::builder::prelude::*;
26
27static INTERFACE: wl_interface = wl_interface {
28 name: c"zwp_tablet_tool_v2".as_ptr(),
29 version: 1,
30 method_count: 2,
31 methods: {
32 static MESSAGES: [wl_message; 2] = [
33 wl_message {
34 name: c"set_cursor".as_ptr(),
35 signature: c"u?oii".as_ptr(),
36 types: {
37 static TYPES: [Option<&'static wl_interface>; 4] =
38 [None, Some(WlSurface::WL_INTERFACE), None, None];
39 TYPES.as_ptr().cast()
40 },
41 },
42 wl_message {
43 name: c"destroy".as_ptr(),
44 signature: c"".as_ptr(),
45 types: {
46 static TYPES: [Option<&'static wl_interface>; 0] = [];
47 TYPES.as_ptr().cast()
48 },
49 },
50 ];
51 MESSAGES.as_ptr()
52 },
53 event_count: 19,
54 events: {
55 static MESSAGES: [wl_message; 19] = [
56 wl_message {
57 name: c"type".as_ptr(),
58 signature: c"u".as_ptr(),
59 types: {
60 static TYPES: [Option<&'static wl_interface>; 1] = [None];
61 TYPES.as_ptr().cast()
62 },
63 },
64 wl_message {
65 name: c"hardware_serial".as_ptr(),
66 signature: c"uu".as_ptr(),
67 types: {
68 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
69 TYPES.as_ptr().cast()
70 },
71 },
72 wl_message {
73 name: c"hardware_id_wacom".as_ptr(),
74 signature: c"uu".as_ptr(),
75 types: {
76 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
77 TYPES.as_ptr().cast()
78 },
79 },
80 wl_message {
81 name: c"capability".as_ptr(),
82 signature: c"u".as_ptr(),
83 types: {
84 static TYPES: [Option<&'static wl_interface>; 1] = [None];
85 TYPES.as_ptr().cast()
86 },
87 },
88 wl_message {
89 name: c"done".as_ptr(),
90 signature: c"".as_ptr(),
91 types: {
92 static TYPES: [Option<&'static wl_interface>; 0] = [];
93 TYPES.as_ptr().cast()
94 },
95 },
96 wl_message {
97 name: c"removed".as_ptr(),
98 signature: c"".as_ptr(),
99 types: {
100 static TYPES: [Option<&'static wl_interface>; 0] = [];
101 TYPES.as_ptr().cast()
102 },
103 },
104 wl_message {
105 name: c"proximity_in".as_ptr(),
106 signature: c"uoo".as_ptr(),
107 types: {
108 static TYPES: [Option<&'static wl_interface>; 3] = [
109 None,
110 Some(ZwpTabletV2::WL_INTERFACE),
111 Some(WlSurface::WL_INTERFACE),
112 ];
113 TYPES.as_ptr().cast()
114 },
115 },
116 wl_message {
117 name: c"proximity_out".as_ptr(),
118 signature: c"".as_ptr(),
119 types: {
120 static TYPES: [Option<&'static wl_interface>; 0] = [];
121 TYPES.as_ptr().cast()
122 },
123 },
124 wl_message {
125 name: c"down".as_ptr(),
126 signature: c"u".as_ptr(),
127 types: {
128 static TYPES: [Option<&'static wl_interface>; 1] = [None];
129 TYPES.as_ptr().cast()
130 },
131 },
132 wl_message {
133 name: c"up".as_ptr(),
134 signature: c"".as_ptr(),
135 types: {
136 static TYPES: [Option<&'static wl_interface>; 0] = [];
137 TYPES.as_ptr().cast()
138 },
139 },
140 wl_message {
141 name: c"motion".as_ptr(),
142 signature: c"ff".as_ptr(),
143 types: {
144 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
145 TYPES.as_ptr().cast()
146 },
147 },
148 wl_message {
149 name: c"pressure".as_ptr(),
150 signature: c"u".as_ptr(),
151 types: {
152 static TYPES: [Option<&'static wl_interface>; 1] = [None];
153 TYPES.as_ptr().cast()
154 },
155 },
156 wl_message {
157 name: c"distance".as_ptr(),
158 signature: c"u".as_ptr(),
159 types: {
160 static TYPES: [Option<&'static wl_interface>; 1] = [None];
161 TYPES.as_ptr().cast()
162 },
163 },
164 wl_message {
165 name: c"tilt".as_ptr(),
166 signature: c"ff".as_ptr(),
167 types: {
168 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
169 TYPES.as_ptr().cast()
170 },
171 },
172 wl_message {
173 name: c"rotation".as_ptr(),
174 signature: c"f".as_ptr(),
175 types: {
176 static TYPES: [Option<&'static wl_interface>; 1] = [None];
177 TYPES.as_ptr().cast()
178 },
179 },
180 wl_message {
181 name: c"slider".as_ptr(),
182 signature: c"i".as_ptr(),
183 types: {
184 static TYPES: [Option<&'static wl_interface>; 1] = [None];
185 TYPES.as_ptr().cast()
186 },
187 },
188 wl_message {
189 name: c"wheel".as_ptr(),
190 signature: c"fi".as_ptr(),
191 types: {
192 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
193 TYPES.as_ptr().cast()
194 },
195 },
196 wl_message {
197 name: c"button".as_ptr(),
198 signature: c"uuu".as_ptr(),
199 types: {
200 static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
201 TYPES.as_ptr().cast()
202 },
203 },
204 wl_message {
205 name: c"frame".as_ptr(),
206 signature: c"u".as_ptr(),
207 types: {
208 static TYPES: [Option<&'static wl_interface>; 1] = [None];
209 TYPES.as_ptr().cast()
210 },
211 },
212 ];
213 MESSAGES.as_ptr()
214 },
215};
216
217/// An owned zwp_tablet_tool_v2 proxy.
218///
219/// See the documentation of [the module][self] for the interface description.
220#[derive(Clone, Eq, PartialEq)]
221#[repr(transparent)]
222pub struct ZwpTabletToolV2 {
223 /// This proxy has the interface INTERFACE.
224 proxy: UntypedOwnedProxy,
225}
226
227/// A borrowed zwp_tablet_tool_v2 proxy.
228///
229/// See the documentation of [the module][self] for the interface description.
230#[derive(Eq, PartialEq)]
231#[repr(transparent)]
232pub struct ZwpTabletToolV2Ref {
233 /// This proxy has the interface INTERFACE.
234 proxy: UntypedBorrowedProxy,
235}
236
237// SAFETY: ZwpTabletToolV2 is a transparent wrapper around UntypedOwnedProxy
238unsafe impl UntypedOwnedProxyWrapper for ZwpTabletToolV2 {}
239
240// SAFETY: - INTERFACE is a valid wl_interface
241// - The only invariant is that self.proxy has a compatible interface
242unsafe impl OwnedProxy for ZwpTabletToolV2 {
243 const INTERFACE: &'static str = "zwp_tablet_tool_v2";
244 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
245 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
246 private::EventHandler(private::NoOpEventHandler);
247 const MAX_VERSION: u32 = 1;
248
249 type Borrowed = ZwpTabletToolV2Ref;
250 type Api = private::ProxyApi;
251 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
252}
253
254// SAFETY: ZwpTabletToolV2Ref is a transparent wrapper around UntypedBorrowedProxy
255unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletToolV2Ref {}
256
257// SAFETY: - The only invariant is that self.proxy has a compatible interface
258unsafe impl BorrowedProxy for ZwpTabletToolV2Ref {
259 type Owned = ZwpTabletToolV2;
260}
261
262impl Deref for ZwpTabletToolV2 {
263 type Target = ZwpTabletToolV2Ref;
264
265 fn deref(&self) -> &Self::Target {
266 proxy::low_level::deref(self)
267 }
268}
269
270mod private {
271 pub struct ProxyApi;
272
273 #[allow(dead_code)]
274 pub struct EventHandler<H>(pub(super) H);
275
276 #[allow(dead_code)]
277 pub struct NoOpEventHandler;
278}
279
280impl Debug for ZwpTabletToolV2 {
281 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
282 write!(f, "zwp_tablet_tool_v2#{}", self.proxy.id())
283 }
284}
285
286impl Debug for ZwpTabletToolV2Ref {
287 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
288 write!(f, "zwp_tablet_tool_v2#{}", self.proxy.id())
289 }
290}
291
292impl PartialEq<ZwpTabletToolV2Ref> for ZwpTabletToolV2 {
293 fn eq(&self, other: &ZwpTabletToolV2Ref) -> bool {
294 self.proxy == other.proxy
295 }
296}
297
298impl PartialEq<ZwpTabletToolV2> for ZwpTabletToolV2Ref {
299 fn eq(&self, other: &ZwpTabletToolV2) -> bool {
300 self.proxy == other.proxy
301 }
302}
303
304#[allow(dead_code)]
305impl ZwpTabletToolV2 {
306 /// Since when the set_cursor request is available.
307 #[allow(dead_code)]
308 pub const REQ__SET_CURSOR__SINCE: u32 = 1;
309
310 /// Since when the destroy request is available.
311 #[allow(dead_code)]
312 pub const REQ__DESTROY__SINCE: u32 = 1;
313}
314
315#[allow(dead_code)]
316impl ZwpTabletToolV2 {
317 /// destroy the tool object
318 ///
319 /// This destroys the client's resource for this tool object.
320 #[inline]
321 pub fn destroy(&self) {
322 let mut args = [];
323 // SAFETY: - self.proxy has the interface INTERFACE
324 // - 1 < INTERFACE.method_count = 2
325 // - the request signature is ``
326 unsafe {
327 self.proxy.send_destructor(1, &mut args);
328 }
329 }
330}
331
332#[allow(dead_code)]
333impl ZwpTabletToolV2Ref {
334 /// set the tablet tool's surface
335 ///
336 /// Sets the surface of the cursor used for this tool on the given
337 /// tablet. This request only takes effect if the tool is in proximity
338 /// of one of the requesting client's surfaces or the surface parameter
339 /// is the current pointer surface. If there was a previous surface set
340 /// with this request it is replaced. If surface is NULL, the cursor
341 /// image is hidden.
342 ///
343 /// The parameters hotspot_x and hotspot_y define the position of the
344 /// pointer surface relative to the pointer location. Its top-left corner
345 /// is always at (x, y) - (hotspot_x, hotspot_y), where (x, y) are the
346 /// coordinates of the pointer location, in surface-local coordinates.
347 ///
348 /// On surface.attach requests to the pointer surface, hotspot_x and
349 /// hotspot_y are decremented by the x and y parameters passed to the
350 /// request. Attach must be confirmed by wl_surface.commit as usual.
351 ///
352 /// The hotspot can also be updated by passing the currently set pointer
353 /// surface to this request with new values for hotspot_x and hotspot_y.
354 ///
355 /// The current and pending input regions of the wl_surface are cleared,
356 /// and wl_surface.set_input_region is ignored until the wl_surface is no
357 /// longer used as the cursor. When the use as a cursor ends, the current
358 /// and pending input regions become undefined, and the wl_surface is
359 /// unmapped.
360 ///
361 /// This request gives the surface the role of a wp_tablet_tool cursor. A
362 /// surface may only ever be used as the cursor surface for one
363 /// wp_tablet_tool. If the surface already has another role or has
364 /// previously been used as cursor surface for a different tool, a
365 /// protocol error is raised.
366 ///
367 /// # Arguments
368 ///
369 /// - `serial`: serial of the proximity_in event
370 /// - `surface`:
371 /// - `hotspot_x`: surface-local x coordinate
372 /// - `hotspot_y`: surface-local y coordinate
373 #[inline]
374 pub fn set_cursor(
375 &self,
376 serial: u32,
377 surface: Option<&WlSurfaceRef>,
378 hotspot_x: i32,
379 hotspot_y: i32,
380 ) {
381 let (arg0, arg1, arg2, arg3) = (serial, surface, hotspot_x, hotspot_y);
382 let obj1_lock = arg1.map(|arg1| proxy::lock(arg1));
383 let obj1 = obj1_lock
384 .map(|obj1_lock| check_argument_proxy("surface", obj1_lock.wl_proxy()))
385 .unwrap_or(ptr::null_mut());
386 let mut args = [
387 wl_argument { u: arg0 },
388 wl_argument { o: obj1 },
389 wl_argument { i: arg2 },
390 wl_argument { i: arg3 },
391 ];
392 // SAFETY: - self.proxy has the interface INTERFACE
393 // - 0 < INTERFACE.method_count = 2
394 // - the request signature is `u?oii`
395 unsafe {
396 self.proxy.send_request(0, &mut args);
397 }
398 }
399}
400
401impl ZwpTabletToolV2 {
402 /// Since when the type event is available.
403 #[allow(dead_code)]
404 pub const EVT__TYPE__SINCE: u32 = 1;
405
406 /// Since when the hardware_serial event is available.
407 #[allow(dead_code)]
408 pub const EVT__HARDWARE_SERIAL__SINCE: u32 = 1;
409
410 /// Since when the hardware_id_wacom event is available.
411 #[allow(dead_code)]
412 pub const EVT__HARDWARE_ID_WACOM__SINCE: u32 = 1;
413
414 /// Since when the capability event is available.
415 #[allow(dead_code)]
416 pub const EVT__CAPABILITY__SINCE: u32 = 1;
417
418 /// Since when the done event is available.
419 #[allow(dead_code)]
420 pub const EVT__DONE__SINCE: u32 = 1;
421
422 /// Since when the removed event is available.
423 #[allow(dead_code)]
424 pub const EVT__REMOVED__SINCE: u32 = 1;
425
426 /// Since when the proximity_in event is available.
427 #[allow(dead_code)]
428 pub const EVT__PROXIMITY_IN__SINCE: u32 = 1;
429
430 /// Since when the proximity_out event is available.
431 #[allow(dead_code)]
432 pub const EVT__PROXIMITY_OUT__SINCE: u32 = 1;
433
434 /// Since when the down event is available.
435 #[allow(dead_code)]
436 pub const EVT__DOWN__SINCE: u32 = 1;
437
438 /// Since when the up event is available.
439 #[allow(dead_code)]
440 pub const EVT__UP__SINCE: u32 = 1;
441
442 /// Since when the motion event is available.
443 #[allow(dead_code)]
444 pub const EVT__MOTION__SINCE: u32 = 1;
445
446 /// Since when the pressure event is available.
447 #[allow(dead_code)]
448 pub const EVT__PRESSURE__SINCE: u32 = 1;
449
450 /// Since when the distance event is available.
451 #[allow(dead_code)]
452 pub const EVT__DISTANCE__SINCE: u32 = 1;
453
454 /// Since when the tilt event is available.
455 #[allow(dead_code)]
456 pub const EVT__TILT__SINCE: u32 = 1;
457
458 /// Since when the rotation event is available.
459 #[allow(dead_code)]
460 pub const EVT__ROTATION__SINCE: u32 = 1;
461
462 /// Since when the slider event is available.
463 #[allow(dead_code)]
464 pub const EVT__SLIDER__SINCE: u32 = 1;
465
466 /// Since when the wheel event is available.
467 #[allow(dead_code)]
468 pub const EVT__WHEEL__SINCE: u32 = 1;
469
470 /// Since when the button event is available.
471 #[allow(dead_code)]
472 pub const EVT__BUTTON__SINCE: u32 = 1;
473
474 /// Since when the frame event is available.
475 #[allow(dead_code)]
476 pub const EVT__FRAME__SINCE: u32 = 1;
477}
478
479/// An event handler for [ZwpTabletToolV2] proxies.
480#[allow(dead_code)]
481pub trait ZwpTabletToolV2EventHandler {
482 /// tool type
483 ///
484 /// The tool type is the high-level type of the tool and usually decides
485 /// the interaction expected from this tool.
486 ///
487 /// This event is sent in the initial burst of events before the
488 /// wp_tablet_tool.done event.
489 ///
490 /// # Arguments
491 ///
492 /// - `tool_type`: the physical tool type
493 #[inline]
494 fn r#type(&self, _slf: &ZwpTabletToolV2Ref, tool_type: ZwpTabletToolV2Type) {
495 let _ = tool_type;
496 }
497
498 /// unique hardware serial number of the tool
499 ///
500 /// If the physical tool can be identified by a unique 64-bit serial
501 /// number, this event notifies the client of this serial number.
502 ///
503 /// If multiple tablets are available in the same seat and the tool is
504 /// uniquely identifiable by the serial number, that tool may move
505 /// between tablets.
506 ///
507 /// Otherwise, if the tool has no serial number and this event is
508 /// missing, the tool is tied to the tablet it first comes into
509 /// proximity with. Even if the physical tool is used on multiple
510 /// tablets, separate wp_tablet_tool objects will be created, one per
511 /// tablet.
512 ///
513 /// This event is sent in the initial burst of events before the
514 /// wp_tablet_tool.done event.
515 ///
516 /// # Arguments
517 ///
518 /// - `hardware_serial_hi`: the unique serial number of the tool, most significant bits
519 /// - `hardware_serial_lo`: the unique serial number of the tool, least significant bits
520 #[inline]
521 fn hardware_serial(
522 &self,
523 _slf: &ZwpTabletToolV2Ref,
524 hardware_serial_hi: u32,
525 hardware_serial_lo: u32,
526 ) {
527 let _ = hardware_serial_hi;
528 let _ = hardware_serial_lo;
529 }
530
531 /// hardware id notification in Wacom's format
532 ///
533 /// This event notifies the client of a hardware id available on this tool.
534 ///
535 /// The hardware id is a device-specific 64-bit id that provides extra
536 /// information about the tool in use, beyond the wl_tool.type
537 /// enumeration. The format of the id is specific to tablets made by
538 /// Wacom Inc. For example, the hardware id of a Wacom Grip
539 /// Pen (a stylus) is 0x802.
540 ///
541 /// This event is sent in the initial burst of events before the
542 /// wp_tablet_tool.done event.
543 ///
544 /// # Arguments
545 ///
546 /// - `hardware_id_hi`: the hardware id, most significant bits
547 /// - `hardware_id_lo`: the hardware id, least significant bits
548 #[inline]
549 fn hardware_id_wacom(
550 &self,
551 _slf: &ZwpTabletToolV2Ref,
552 hardware_id_hi: u32,
553 hardware_id_lo: u32,
554 ) {
555 let _ = hardware_id_hi;
556 let _ = hardware_id_lo;
557 }
558
559 /// tool capability notification
560 ///
561 /// This event notifies the client of any capabilities of this tool,
562 /// beyond the main set of x/y axes and tip up/down detection.
563 ///
564 /// One event is sent for each extra capability available on this tool.
565 ///
566 /// This event is sent in the initial burst of events before the
567 /// wp_tablet_tool.done event.
568 ///
569 /// # Arguments
570 ///
571 /// - `capability`: the capability
572 #[inline]
573 fn capability(&self, _slf: &ZwpTabletToolV2Ref, capability: ZwpTabletToolV2Capability) {
574 let _ = capability;
575 }
576
577 /// tool description events sequence complete
578 ///
579 /// This event signals the end of the initial burst of descriptive
580 /// events. A client may consider the static description of the tool to
581 /// be complete and finalize initialization of the tool.
582 #[inline]
583 fn done(&self, _slf: &ZwpTabletToolV2Ref) {}
584
585 /// tool removed
586 ///
587 /// This event is sent when the tool is removed from the system and will
588 /// send no further events. Should the physical tool come back into
589 /// proximity later, a new wp_tablet_tool object will be created.
590 ///
591 /// It is compositor-dependent when a tool is removed. A compositor may
592 /// remove a tool on proximity out, tablet removal or any other reason.
593 /// A compositor may also keep a tool alive until shutdown.
594 ///
595 /// If the tool is currently in proximity, a proximity_out event will be
596 /// sent before the removed event. See wp_tablet_tool.proximity_out for
597 /// the handling of any buttons logically down.
598 ///
599 /// When this event is received, the client must wp_tablet_tool.destroy
600 /// the object.
601 #[inline]
602 fn removed(&self, _slf: &ZwpTabletToolV2Ref) {}
603
604 /// proximity in event
605 ///
606 /// Notification that this tool is focused on a certain surface.
607 ///
608 /// This event can be received when the tool has moved from one surface to
609 /// another, or when the tool has come back into proximity above the
610 /// surface.
611 ///
612 /// If any button is logically down when the tool comes into proximity,
613 /// the respective button event is sent after the proximity_in event but
614 /// within the same frame as the proximity_in event.
615 ///
616 /// # Arguments
617 ///
618 /// - `serial`:
619 /// - `tablet`: The tablet the tool is in proximity of
620 /// - `surface`: The current surface the tablet tool is over
621 ///
622 /// All borrowed proxies passed to this function are guaranteed to be
623 /// immutable and non-null.
624 #[inline]
625 fn proximity_in(
626 &self,
627 _slf: &ZwpTabletToolV2Ref,
628 serial: u32,
629 tablet: Option<&ZwpTabletV2Ref>,
630 surface: Option<&WlSurfaceRef>,
631 ) {
632 let _ = serial;
633 let _ = tablet;
634 let _ = surface;
635 }
636
637 /// proximity out event
638 ///
639 /// Notification that this tool has either left proximity, or is no
640 /// longer focused on a certain surface.
641 ///
642 /// When the tablet tool leaves proximity of the tablet, button release
643 /// events are sent for each button that was held down at the time of
644 /// leaving proximity. These events are sent before the proximity_out
645 /// event but within the same wp_tablet.frame.
646 ///
647 /// If the tool stays within proximity of the tablet, but the focus
648 /// changes from one surface to another, a button release event may not
649 /// be sent until the button is actually released or the tool leaves the
650 /// proximity of the tablet.
651 #[inline]
652 fn proximity_out(&self, _slf: &ZwpTabletToolV2Ref) {}
653
654 /// tablet tool is making contact
655 ///
656 /// Sent whenever the tablet tool comes in contact with the surface of the
657 /// tablet.
658 ///
659 /// If the tool is already in contact with the tablet when entering the
660 /// input region, the client owning said region will receive a
661 /// wp_tablet.proximity_in event, followed by a wp_tablet.down
662 /// event and a wp_tablet.frame event.
663 ///
664 /// Note that this event describes logical contact, not physical
665 /// contact. On some devices, a compositor may not consider a tool in
666 /// logical contact until a minimum physical pressure threshold is
667 /// exceeded.
668 ///
669 /// # Arguments
670 ///
671 /// - `serial`:
672 #[inline]
673 fn down(&self, _slf: &ZwpTabletToolV2Ref, serial: u32) {
674 let _ = serial;
675 }
676
677 /// tablet tool is no longer making contact
678 ///
679 /// Sent whenever the tablet tool stops making contact with the surface of
680 /// the tablet, or when the tablet tool moves out of the input region
681 /// and the compositor grab (if any) is dismissed.
682 ///
683 /// If the tablet tool moves out of the input region while in contact
684 /// with the surface of the tablet and the compositor does not have an
685 /// ongoing grab on the surface, the client owning said region will
686 /// receive a wp_tablet.up event, followed by a wp_tablet.proximity_out
687 /// event and a wp_tablet.frame event. If the compositor has an ongoing
688 /// grab on this device, this event sequence is sent whenever the grab
689 /// is dismissed in the future.
690 ///
691 /// Note that this event describes logical contact, not physical
692 /// contact. On some devices, a compositor may not consider a tool out
693 /// of logical contact until physical pressure falls below a specific
694 /// threshold.
695 #[inline]
696 fn up(&self, _slf: &ZwpTabletToolV2Ref) {}
697
698 /// motion event
699 ///
700 /// Sent whenever a tablet tool moves.
701 ///
702 /// # Arguments
703 ///
704 /// - `x`: surface-local x coordinate
705 /// - `y`: surface-local y coordinate
706 #[inline]
707 fn motion(&self, _slf: &ZwpTabletToolV2Ref, x: Fixed, y: Fixed) {
708 let _ = x;
709 let _ = y;
710 }
711
712 /// pressure change event
713 ///
714 /// Sent whenever the pressure axis on a tool changes. The value of this
715 /// event is normalized to a value between 0 and 65535.
716 ///
717 /// Note that pressure may be nonzero even when a tool is not in logical
718 /// contact. See the down and up events for more details.
719 ///
720 /// # Arguments
721 ///
722 /// - `pressure`: The current pressure value
723 #[inline]
724 fn pressure(&self, _slf: &ZwpTabletToolV2Ref, pressure: u32) {
725 let _ = pressure;
726 }
727
728 /// distance change event
729 ///
730 /// Sent whenever the distance axis on a tool changes. The value of this
731 /// event is normalized to a value between 0 and 65535.
732 ///
733 /// Note that distance may be nonzero even when a tool is not in logical
734 /// contact. See the down and up events for more details.
735 ///
736 /// # Arguments
737 ///
738 /// - `distance`: The current distance value
739 #[inline]
740 fn distance(&self, _slf: &ZwpTabletToolV2Ref, distance: u32) {
741 let _ = distance;
742 }
743
744 /// tilt change event
745 ///
746 /// Sent whenever one or both of the tilt axes on a tool change. Each tilt
747 /// value is in degrees, relative to the z-axis of the tablet.
748 /// The angle is positive when the top of a tool tilts along the
749 /// positive x or y axis.
750 ///
751 /// # Arguments
752 ///
753 /// - `tilt_x`: The current value of the X tilt axis
754 /// - `tilt_y`: The current value of the Y tilt axis
755 #[inline]
756 fn tilt(&self, _slf: &ZwpTabletToolV2Ref, tilt_x: Fixed, tilt_y: Fixed) {
757 let _ = tilt_x;
758 let _ = tilt_y;
759 }
760
761 /// z-rotation change event
762 ///
763 /// Sent whenever the z-rotation axis on the tool changes. The
764 /// rotation value is in degrees clockwise from the tool's
765 /// logical neutral position.
766 ///
767 /// # Arguments
768 ///
769 /// - `degrees`: The current rotation of the Z axis
770 #[inline]
771 fn rotation(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed) {
772 let _ = degrees;
773 }
774
775 /// Slider position change event
776 ///
777 /// Sent whenever the slider position on the tool changes. The
778 /// value is normalized between -65535 and 65535, with 0 as the logical
779 /// neutral position of the slider.
780 ///
781 /// The slider is available on e.g. the Wacom Airbrush tool.
782 ///
783 /// # Arguments
784 ///
785 /// - `position`: The current position of slider
786 #[inline]
787 fn slider(&self, _slf: &ZwpTabletToolV2Ref, position: i32) {
788 let _ = position;
789 }
790
791 /// Wheel delta event
792 ///
793 /// Sent whenever the wheel on the tool emits an event. This event
794 /// contains two values for the same axis change. The degrees value is
795 /// in the same orientation as the wl_pointer.vertical_scroll axis. The
796 /// clicks value is in discrete logical clicks of the mouse wheel. This
797 /// value may be zero if the movement of the wheel was less
798 /// than one logical click.
799 ///
800 /// Clients should choose either value and avoid mixing degrees and
801 /// clicks. The compositor may accumulate values smaller than a logical
802 /// click and emulate click events when a certain threshold is met.
803 /// Thus, wl_tablet_tool.wheel events with non-zero clicks values may
804 /// have different degrees values.
805 ///
806 /// # Arguments
807 ///
808 /// - `degrees`: The wheel delta in degrees
809 /// - `clicks`: The wheel delta in discrete clicks
810 #[inline]
811 fn wheel(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed, clicks: i32) {
812 let _ = degrees;
813 let _ = clicks;
814 }
815
816 /// button event
817 ///
818 /// Sent whenever a button on the tool is pressed or released.
819 ///
820 /// If a button is held down when the tool moves in or out of proximity,
821 /// button events are generated by the compositor. See
822 /// wp_tablet_tool.proximity_in and wp_tablet_tool.proximity_out for
823 /// details.
824 ///
825 /// # Arguments
826 ///
827 /// - `serial`:
828 /// - `button`: The button whose state has changed
829 /// - `state`: Whether the button was pressed or released
830 #[inline]
831 fn button(
832 &self,
833 _slf: &ZwpTabletToolV2Ref,
834 serial: u32,
835 button: u32,
836 state: ZwpTabletToolV2ButtonState,
837 ) {
838 let _ = serial;
839 let _ = button;
840 let _ = state;
841 }
842
843 /// frame event
844 ///
845 /// Marks the end of a series of axis and/or button updates from the
846 /// tablet. The Wayland protocol requires axis updates to be sent
847 /// sequentially, however all events within a frame should be considered
848 /// one hardware event.
849 ///
850 /// # Arguments
851 ///
852 /// - `time`: The time of the event with millisecond granularity
853 #[inline]
854 fn frame(&self, _slf: &ZwpTabletToolV2Ref, time: u32) {
855 let _ = time;
856 }
857}
858
859impl ZwpTabletToolV2EventHandler for private::NoOpEventHandler {}
860
861// SAFETY: - INTERFACE is a valid wl_interface
862unsafe impl<H> EventHandler for private::EventHandler<H>
863where
864 H: ZwpTabletToolV2EventHandler,
865{
866 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
867
868 #[allow(unused_variables)]
869 unsafe fn handle_event(
870 &self,
871 queue: &Queue,
872 data: *mut u8,
873 slf: &UntypedBorrowedProxy,
874 opcode: u32,
875 args: *mut wl_argument,
876 ) {
877 // SAFETY: This function requires that slf has the interface INTERFACE
878 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletToolV2Ref>(slf) };
879 match opcode {
880 0 => {
881 // SAFETY: INTERFACE requires that there are 1 arguments
882 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
883 // SAFETY: - INTERFACE requires that args[0] contains a uint
884 let arg0 = unsafe { ZwpTabletToolV2Type(args[0].u) };
885 self.0.r#type(slf, arg0);
886 }
887 1 => {
888 // SAFETY: INTERFACE requires that there are 2 arguments
889 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
890 // SAFETY: - INTERFACE requires that args[0] contains a uint
891 let arg0 = unsafe { args[0].u };
892 // SAFETY: - INTERFACE requires that args[1] contains a uint
893 let arg1 = unsafe { args[1].u };
894 self.0.hardware_serial(slf, arg0, arg1);
895 }
896 2 => {
897 // SAFETY: INTERFACE requires that there are 2 arguments
898 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
899 // SAFETY: - INTERFACE requires that args[0] contains a uint
900 let arg0 = unsafe { args[0].u };
901 // SAFETY: - INTERFACE requires that args[1] contains a uint
902 let arg1 = unsafe { args[1].u };
903 self.0.hardware_id_wacom(slf, arg0, arg1);
904 }
905 3 => {
906 // SAFETY: INTERFACE requires that there are 1 arguments
907 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
908 // SAFETY: - INTERFACE requires that args[0] contains a uint
909 let arg0 = unsafe { ZwpTabletToolV2Capability(args[0].u) };
910 self.0.capability(slf, arg0);
911 }
912 4 => {
913 self.0.done(slf);
914 }
915 5 => {
916 self.0.removed(slf);
917 }
918 6 => {
919 // SAFETY: INTERFACE requires that there are 3 arguments
920 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
921 // SAFETY: - INTERFACE requires that args[0] contains a uint
922 let arg0 = unsafe { args[0].u };
923 // SAFETY: - INTERFACE requires that args[1] contains an object
924 let arg1 = unsafe {
925 if let Some(p) = NonNull::new(args[1].o.cast()) {
926 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
927 } else {
928 None
929 }
930 };
931 // SAFETY: - INTERFACE requires that the object has the interface ZwpTabletV2::WL_INTERFACE
932 let arg1 = arg1.as_ref().map(|arg1| unsafe {
933 proxy::low_level::from_untyped_borrowed::<ZwpTabletV2Ref>(arg1)
934 });
935 // SAFETY: - INTERFACE requires that args[2] contains an object
936 let arg2 = unsafe {
937 if let Some(p) = NonNull::new(args[2].o.cast()) {
938 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
939 } else {
940 None
941 }
942 };
943 // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
944 let arg2 = arg2.as_ref().map(|arg2| unsafe {
945 proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg2)
946 });
947 self.0.proximity_in(slf, arg0, arg1, arg2);
948 }
949 7 => {
950 self.0.proximity_out(slf);
951 }
952 8 => {
953 // SAFETY: INTERFACE requires that there are 1 arguments
954 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
955 // SAFETY: - INTERFACE requires that args[0] contains a uint
956 let arg0 = unsafe { args[0].u };
957 self.0.down(slf, arg0);
958 }
959 9 => {
960 self.0.up(slf);
961 }
962 10 => {
963 // SAFETY: INTERFACE requires that there are 2 arguments
964 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
965 // SAFETY: - INTERFACE requires that args[0] contains a fixed
966 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
967 // SAFETY: - INTERFACE requires that args[1] contains a fixed
968 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
969 self.0.motion(slf, arg0, arg1);
970 }
971 11 => {
972 // SAFETY: INTERFACE requires that there are 1 arguments
973 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
974 // SAFETY: - INTERFACE requires that args[0] contains a uint
975 let arg0 = unsafe { args[0].u };
976 self.0.pressure(slf, arg0);
977 }
978 12 => {
979 // SAFETY: INTERFACE requires that there are 1 arguments
980 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
981 // SAFETY: - INTERFACE requires that args[0] contains a uint
982 let arg0 = unsafe { args[0].u };
983 self.0.distance(slf, arg0);
984 }
985 13 => {
986 // SAFETY: INTERFACE requires that there are 2 arguments
987 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
988 // SAFETY: - INTERFACE requires that args[0] contains a fixed
989 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
990 // SAFETY: - INTERFACE requires that args[1] contains a fixed
991 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
992 self.0.tilt(slf, arg0, arg1);
993 }
994 14 => {
995 // SAFETY: INTERFACE requires that there are 1 arguments
996 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
997 // SAFETY: - INTERFACE requires that args[0] contains a fixed
998 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
999 self.0.rotation(slf, arg0);
1000 }
1001 15 => {
1002 // SAFETY: INTERFACE requires that there are 1 arguments
1003 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
1004 // SAFETY: - INTERFACE requires that args[0] contains an int
1005 let arg0 = unsafe { args[0].i };
1006 self.0.slider(slf, arg0);
1007 }
1008 16 => {
1009 // SAFETY: INTERFACE requires that there are 2 arguments
1010 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
1011 // SAFETY: - INTERFACE requires that args[0] contains a fixed
1012 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
1013 // SAFETY: - INTERFACE requires that args[1] contains an int
1014 let arg1 = unsafe { args[1].i };
1015 self.0.wheel(slf, arg0, arg1);
1016 }
1017 17 => {
1018 // SAFETY: INTERFACE requires that there are 3 arguments
1019 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
1020 // SAFETY: - INTERFACE requires that args[0] contains a uint
1021 let arg0 = unsafe { args[0].u };
1022 // SAFETY: - INTERFACE requires that args[1] contains a uint
1023 let arg1 = unsafe { args[1].u };
1024 // SAFETY: - INTERFACE requires that args[2] contains a uint
1025 let arg2 = unsafe { ZwpTabletToolV2ButtonState(args[2].u) };
1026 self.0.button(slf, arg0, arg1, arg2);
1027 }
1028 18 => {
1029 // SAFETY: INTERFACE requires that there are 1 arguments
1030 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
1031 // SAFETY: - INTERFACE requires that args[0] contains a uint
1032 let arg0 = unsafe { args[0].u };
1033 self.0.frame(slf, arg0);
1034 }
1035 _ => {
1036 invalid_opcode("zwp_tablet_tool_v2", opcode);
1037 }
1038 }
1039 }
1040}
1041
1042impl<H> CreateEventHandler<H> for private::ProxyApi
1043where
1044 H: ZwpTabletToolV2EventHandler,
1045{
1046 type EventHandler = private::EventHandler<H>;
1047
1048 #[inline]
1049 fn create_event_handler(handler: H) -> Self::EventHandler {
1050 private::EventHandler(handler)
1051 }
1052}
1053
1054impl ZwpTabletToolV2 {
1055 /// Since when the type.pen enum variant is available.
1056 #[allow(dead_code)]
1057 pub const ENM__TYPE_PEN__SINCE: u32 = 1;
1058 /// Since when the type.eraser enum variant is available.
1059 #[allow(dead_code)]
1060 pub const ENM__TYPE_ERASER__SINCE: u32 = 1;
1061 /// Since when the type.brush enum variant is available.
1062 #[allow(dead_code)]
1063 pub const ENM__TYPE_BRUSH__SINCE: u32 = 1;
1064 /// Since when the type.pencil enum variant is available.
1065 #[allow(dead_code)]
1066 pub const ENM__TYPE_PENCIL__SINCE: u32 = 1;
1067 /// Since when the type.airbrush enum variant is available.
1068 #[allow(dead_code)]
1069 pub const ENM__TYPE_AIRBRUSH__SINCE: u32 = 1;
1070 /// Since when the type.finger enum variant is available.
1071 #[allow(dead_code)]
1072 pub const ENM__TYPE_FINGER__SINCE: u32 = 1;
1073 /// Since when the type.mouse enum variant is available.
1074 #[allow(dead_code)]
1075 pub const ENM__TYPE_MOUSE__SINCE: u32 = 1;
1076 /// Since when the type.lens enum variant is available.
1077 #[allow(dead_code)]
1078 pub const ENM__TYPE_LENS__SINCE: u32 = 1;
1079
1080 /// Since when the capability.tilt enum variant is available.
1081 #[allow(dead_code)]
1082 pub const ENM__CAPABILITY_TILT__SINCE: u32 = 1;
1083 /// Since when the capability.pressure enum variant is available.
1084 #[allow(dead_code)]
1085 pub const ENM__CAPABILITY_PRESSURE__SINCE: u32 = 1;
1086 /// Since when the capability.distance enum variant is available.
1087 #[allow(dead_code)]
1088 pub const ENM__CAPABILITY_DISTANCE__SINCE: u32 = 1;
1089 /// Since when the capability.rotation enum variant is available.
1090 #[allow(dead_code)]
1091 pub const ENM__CAPABILITY_ROTATION__SINCE: u32 = 1;
1092 /// Since when the capability.slider enum variant is available.
1093 #[allow(dead_code)]
1094 pub const ENM__CAPABILITY_SLIDER__SINCE: u32 = 1;
1095 /// Since when the capability.wheel enum variant is available.
1096 #[allow(dead_code)]
1097 pub const ENM__CAPABILITY_WHEEL__SINCE: u32 = 1;
1098
1099 /// Since when the button_state.released enum variant is available.
1100 #[allow(dead_code)]
1101 pub const ENM__BUTTON_STATE_RELEASED__SINCE: u32 = 1;
1102 /// Since when the button_state.pressed enum variant is available.
1103 #[allow(dead_code)]
1104 pub const ENM__BUTTON_STATE_PRESSED__SINCE: u32 = 1;
1105
1106 /// Since when the error.role enum variant is available.
1107 #[allow(dead_code)]
1108 pub const ENM__ERROR_ROLE__SINCE: u32 = 1;
1109}
1110
1111/// a physical tool type
1112///
1113/// Describes the physical type of a tool. The physical type of a tool
1114/// generally defines its base usage.
1115///
1116/// The mouse tool represents a mouse-shaped tool that is not a relative
1117/// device but bound to the tablet's surface, providing absolute
1118/// coordinates.
1119///
1120/// The lens tool is a mouse-shaped tool with an attached lens to
1121/// provide precision focus.
1122#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1123#[allow(dead_code)]
1124pub struct ZwpTabletToolV2Type(pub u32);
1125
1126impl ZwpTabletToolV2Type {
1127 /// Pen
1128 #[allow(dead_code)]
1129 pub const PEN: Self = Self(0x140);
1130
1131 /// Eraser
1132 #[allow(dead_code)]
1133 pub const ERASER: Self = Self(0x141);
1134
1135 /// Brush
1136 #[allow(dead_code)]
1137 pub const BRUSH: Self = Self(0x142);
1138
1139 /// Pencil
1140 #[allow(dead_code)]
1141 pub const PENCIL: Self = Self(0x143);
1142
1143 /// Airbrush
1144 #[allow(dead_code)]
1145 pub const AIRBRUSH: Self = Self(0x144);
1146
1147 /// Finger
1148 #[allow(dead_code)]
1149 pub const FINGER: Self = Self(0x145);
1150
1151 /// Mouse
1152 #[allow(dead_code)]
1153 pub const MOUSE: Self = Self(0x146);
1154
1155 /// Lens
1156 #[allow(dead_code)]
1157 pub const LENS: Self = Self(0x147);
1158}
1159
1160impl Debug for ZwpTabletToolV2Type {
1161 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1162 let name = match *self {
1163 Self::PEN => "PEN",
1164 Self::ERASER => "ERASER",
1165 Self::BRUSH => "BRUSH",
1166 Self::PENCIL => "PENCIL",
1167 Self::AIRBRUSH => "AIRBRUSH",
1168 Self::FINGER => "FINGER",
1169 Self::MOUSE => "MOUSE",
1170 Self::LENS => "LENS",
1171 _ => return Debug::fmt(&self.0, f),
1172 };
1173 f.write_str(name)
1174 }
1175}
1176
1177/// capability flags for a tool
1178///
1179/// Describes extra capabilities on a tablet.
1180///
1181/// Any tool must provide x and y values, extra axes are
1182/// device-specific.
1183#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1184#[allow(dead_code)]
1185pub struct ZwpTabletToolV2Capability(pub u32);
1186
1187impl ZwpTabletToolV2Capability {
1188 /// Tilt axes
1189 #[allow(dead_code)]
1190 pub const TILT: Self = Self(1);
1191
1192 /// Pressure axis
1193 #[allow(dead_code)]
1194 pub const PRESSURE: Self = Self(2);
1195
1196 /// Distance axis
1197 #[allow(dead_code)]
1198 pub const DISTANCE: Self = Self(3);
1199
1200 /// Z-rotation axis
1201 #[allow(dead_code)]
1202 pub const ROTATION: Self = Self(4);
1203
1204 /// Slider axis
1205 #[allow(dead_code)]
1206 pub const SLIDER: Self = Self(5);
1207
1208 /// Wheel axis
1209 #[allow(dead_code)]
1210 pub const WHEEL: Self = Self(6);
1211}
1212
1213impl Debug for ZwpTabletToolV2Capability {
1214 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1215 let name = match *self {
1216 Self::TILT => "TILT",
1217 Self::PRESSURE => "PRESSURE",
1218 Self::DISTANCE => "DISTANCE",
1219 Self::ROTATION => "ROTATION",
1220 Self::SLIDER => "SLIDER",
1221 Self::WHEEL => "WHEEL",
1222 _ => return Debug::fmt(&self.0, f),
1223 };
1224 f.write_str(name)
1225 }
1226}
1227
1228/// physical button state
1229///
1230/// Describes the physical state of a button that produced the button event.
1231#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1232#[allow(dead_code)]
1233pub struct ZwpTabletToolV2ButtonState(pub u32);
1234
1235impl ZwpTabletToolV2ButtonState {
1236 /// button is not pressed
1237 #[allow(dead_code)]
1238 pub const RELEASED: Self = Self(0);
1239
1240 /// button is pressed
1241 #[allow(dead_code)]
1242 pub const PRESSED: Self = Self(1);
1243}
1244
1245impl Debug for ZwpTabletToolV2ButtonState {
1246 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1247 let name = match *self {
1248 Self::RELEASED => "RELEASED",
1249 Self::PRESSED => "PRESSED",
1250 _ => return Debug::fmt(&self.0, f),
1251 };
1252 f.write_str(name)
1253 }
1254}
1255
1256#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1257#[allow(dead_code)]
1258pub struct ZwpTabletToolV2Error(pub u32);
1259
1260impl ZwpTabletToolV2Error {
1261 /// given wl_surface has another role
1262 #[allow(dead_code)]
1263 pub const ROLE: Self = Self(0);
1264}
1265
1266impl Debug for ZwpTabletToolV2Error {
1267 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1268 let name = match *self {
1269 Self::ROLE => "ROLE",
1270 _ => return Debug::fmt(&self.0, f),
1271 };
1272 f.write_str(name)
1273 }
1274}
1275
1276/// Functional event handlers.
1277pub mod event_handlers {
1278 use super::*;
1279
1280 /// Event handler for type events.
1281 pub struct Type<F>(F);
1282 impl<F> ZwpTabletToolV2EventHandler for Type<F>
1283 where
1284 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Type),
1285 {
1286 #[inline]
1287 fn r#type(&self, _slf: &ZwpTabletToolV2Ref, tool_type: ZwpTabletToolV2Type) {
1288 self.0(_slf, tool_type)
1289 }
1290 }
1291
1292 /// Event handler for hardware_serial events.
1293 pub struct HardwareSerial<F>(F);
1294 impl<F> ZwpTabletToolV2EventHandler for HardwareSerial<F>
1295 where
1296 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1297 {
1298 #[inline]
1299 fn hardware_serial(
1300 &self,
1301 _slf: &ZwpTabletToolV2Ref,
1302 hardware_serial_hi: u32,
1303 hardware_serial_lo: u32,
1304 ) {
1305 self.0(_slf, hardware_serial_hi, hardware_serial_lo)
1306 }
1307 }
1308
1309 /// Event handler for hardware_id_wacom events.
1310 pub struct HardwareIdWacom<F>(F);
1311 impl<F> ZwpTabletToolV2EventHandler for HardwareIdWacom<F>
1312 where
1313 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1314 {
1315 #[inline]
1316 fn hardware_id_wacom(
1317 &self,
1318 _slf: &ZwpTabletToolV2Ref,
1319 hardware_id_hi: u32,
1320 hardware_id_lo: u32,
1321 ) {
1322 self.0(_slf, hardware_id_hi, hardware_id_lo)
1323 }
1324 }
1325
1326 /// Event handler for capability events.
1327 pub struct Capability<F>(F);
1328 impl<F> ZwpTabletToolV2EventHandler for Capability<F>
1329 where
1330 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Capability),
1331 {
1332 #[inline]
1333 fn capability(&self, _slf: &ZwpTabletToolV2Ref, capability: ZwpTabletToolV2Capability) {
1334 self.0(_slf, capability)
1335 }
1336 }
1337
1338 /// Event handler for done events.
1339 pub struct Done<F>(F);
1340 impl<F> ZwpTabletToolV2EventHandler for Done<F>
1341 where
1342 F: Fn(&ZwpTabletToolV2Ref),
1343 {
1344 #[inline]
1345 fn done(&self, _slf: &ZwpTabletToolV2Ref) {
1346 self.0(_slf)
1347 }
1348 }
1349
1350 /// Event handler for removed events.
1351 pub struct Removed<F>(F);
1352 impl<F> ZwpTabletToolV2EventHandler for Removed<F>
1353 where
1354 F: Fn(&ZwpTabletToolV2Ref),
1355 {
1356 #[inline]
1357 fn removed(&self, _slf: &ZwpTabletToolV2Ref) {
1358 self.0(_slf)
1359 }
1360 }
1361
1362 /// Event handler for proximity_in events.
1363 pub struct ProximityIn<F>(F);
1364 impl<F> ZwpTabletToolV2EventHandler for ProximityIn<F>
1365 where
1366 F: Fn(&ZwpTabletToolV2Ref, u32, Option<&ZwpTabletV2Ref>, Option<&WlSurfaceRef>),
1367 {
1368 #[inline]
1369 fn proximity_in(
1370 &self,
1371 _slf: &ZwpTabletToolV2Ref,
1372 serial: u32,
1373 tablet: Option<&ZwpTabletV2Ref>,
1374 surface: Option<&WlSurfaceRef>,
1375 ) {
1376 self.0(_slf, serial, tablet, surface)
1377 }
1378 }
1379
1380 /// Event handler for proximity_out events.
1381 pub struct ProximityOut<F>(F);
1382 impl<F> ZwpTabletToolV2EventHandler for ProximityOut<F>
1383 where
1384 F: Fn(&ZwpTabletToolV2Ref),
1385 {
1386 #[inline]
1387 fn proximity_out(&self, _slf: &ZwpTabletToolV2Ref) {
1388 self.0(_slf)
1389 }
1390 }
1391
1392 /// Event handler for down events.
1393 pub struct Down<F>(F);
1394 impl<F> ZwpTabletToolV2EventHandler for Down<F>
1395 where
1396 F: Fn(&ZwpTabletToolV2Ref, u32),
1397 {
1398 #[inline]
1399 fn down(&self, _slf: &ZwpTabletToolV2Ref, serial: u32) {
1400 self.0(_slf, serial)
1401 }
1402 }
1403
1404 /// Event handler for up events.
1405 pub struct Up<F>(F);
1406 impl<F> ZwpTabletToolV2EventHandler for Up<F>
1407 where
1408 F: Fn(&ZwpTabletToolV2Ref),
1409 {
1410 #[inline]
1411 fn up(&self, _slf: &ZwpTabletToolV2Ref) {
1412 self.0(_slf)
1413 }
1414 }
1415
1416 /// Event handler for motion events.
1417 pub struct Motion<F>(F);
1418 impl<F> ZwpTabletToolV2EventHandler for Motion<F>
1419 where
1420 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1421 {
1422 #[inline]
1423 fn motion(&self, _slf: &ZwpTabletToolV2Ref, x: Fixed, y: Fixed) {
1424 self.0(_slf, x, y)
1425 }
1426 }
1427
1428 /// Event handler for pressure events.
1429 pub struct Pressure<F>(F);
1430 impl<F> ZwpTabletToolV2EventHandler for Pressure<F>
1431 where
1432 F: Fn(&ZwpTabletToolV2Ref, u32),
1433 {
1434 #[inline]
1435 fn pressure(&self, _slf: &ZwpTabletToolV2Ref, pressure: u32) {
1436 self.0(_slf, pressure)
1437 }
1438 }
1439
1440 /// Event handler for distance events.
1441 pub struct Distance<F>(F);
1442 impl<F> ZwpTabletToolV2EventHandler for Distance<F>
1443 where
1444 F: Fn(&ZwpTabletToolV2Ref, u32),
1445 {
1446 #[inline]
1447 fn distance(&self, _slf: &ZwpTabletToolV2Ref, distance: u32) {
1448 self.0(_slf, distance)
1449 }
1450 }
1451
1452 /// Event handler for tilt events.
1453 pub struct Tilt<F>(F);
1454 impl<F> ZwpTabletToolV2EventHandler for Tilt<F>
1455 where
1456 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1457 {
1458 #[inline]
1459 fn tilt(&self, _slf: &ZwpTabletToolV2Ref, tilt_x: Fixed, tilt_y: Fixed) {
1460 self.0(_slf, tilt_x, tilt_y)
1461 }
1462 }
1463
1464 /// Event handler for rotation events.
1465 pub struct Rotation<F>(F);
1466 impl<F> ZwpTabletToolV2EventHandler for Rotation<F>
1467 where
1468 F: Fn(&ZwpTabletToolV2Ref, Fixed),
1469 {
1470 #[inline]
1471 fn rotation(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed) {
1472 self.0(_slf, degrees)
1473 }
1474 }
1475
1476 /// Event handler for slider events.
1477 pub struct Slider<F>(F);
1478 impl<F> ZwpTabletToolV2EventHandler for Slider<F>
1479 where
1480 F: Fn(&ZwpTabletToolV2Ref, i32),
1481 {
1482 #[inline]
1483 fn slider(&self, _slf: &ZwpTabletToolV2Ref, position: i32) {
1484 self.0(_slf, position)
1485 }
1486 }
1487
1488 /// Event handler for wheel events.
1489 pub struct Wheel<F>(F);
1490 impl<F> ZwpTabletToolV2EventHandler for Wheel<F>
1491 where
1492 F: Fn(&ZwpTabletToolV2Ref, Fixed, i32),
1493 {
1494 #[inline]
1495 fn wheel(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed, clicks: i32) {
1496 self.0(_slf, degrees, clicks)
1497 }
1498 }
1499
1500 /// Event handler for button events.
1501 pub struct Button<F>(F);
1502 impl<F> ZwpTabletToolV2EventHandler for Button<F>
1503 where
1504 F: Fn(&ZwpTabletToolV2Ref, u32, u32, ZwpTabletToolV2ButtonState),
1505 {
1506 #[inline]
1507 fn button(
1508 &self,
1509 _slf: &ZwpTabletToolV2Ref,
1510 serial: u32,
1511 button: u32,
1512 state: ZwpTabletToolV2ButtonState,
1513 ) {
1514 self.0(_slf, serial, button, state)
1515 }
1516 }
1517
1518 /// Event handler for frame events.
1519 pub struct Frame<F>(F);
1520 impl<F> ZwpTabletToolV2EventHandler for Frame<F>
1521 where
1522 F: Fn(&ZwpTabletToolV2Ref, u32),
1523 {
1524 #[inline]
1525 fn frame(&self, _slf: &ZwpTabletToolV2Ref, time: u32) {
1526 self.0(_slf, time)
1527 }
1528 }
1529
1530 impl ZwpTabletToolV2 {
1531 /// Creates an event handler for type events.
1532 ///
1533 /// The event handler ignores all other events.
1534 #[allow(dead_code)]
1535 pub fn on_type<F>(f: F) -> Type<F>
1536 where
1537 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Type),
1538 {
1539 Type(f)
1540 }
1541
1542 /// Creates an event handler for hardware_serial events.
1543 ///
1544 /// The event handler ignores all other events.
1545 #[allow(dead_code)]
1546 pub fn on_hardware_serial<F>(f: F) -> HardwareSerial<F>
1547 where
1548 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1549 {
1550 HardwareSerial(f)
1551 }
1552
1553 /// Creates an event handler for hardware_id_wacom events.
1554 ///
1555 /// The event handler ignores all other events.
1556 #[allow(dead_code)]
1557 pub fn on_hardware_id_wacom<F>(f: F) -> HardwareIdWacom<F>
1558 where
1559 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1560 {
1561 HardwareIdWacom(f)
1562 }
1563
1564 /// Creates an event handler for capability events.
1565 ///
1566 /// The event handler ignores all other events.
1567 #[allow(dead_code)]
1568 pub fn on_capability<F>(f: F) -> Capability<F>
1569 where
1570 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Capability),
1571 {
1572 Capability(f)
1573 }
1574
1575 /// Creates an event handler for done events.
1576 ///
1577 /// The event handler ignores all other events.
1578 #[allow(dead_code)]
1579 pub fn on_done<F>(f: F) -> Done<F>
1580 where
1581 F: Fn(&ZwpTabletToolV2Ref),
1582 {
1583 Done(f)
1584 }
1585
1586 /// Creates an event handler for removed events.
1587 ///
1588 /// The event handler ignores all other events.
1589 #[allow(dead_code)]
1590 pub fn on_removed<F>(f: F) -> Removed<F>
1591 where
1592 F: Fn(&ZwpTabletToolV2Ref),
1593 {
1594 Removed(f)
1595 }
1596
1597 /// Creates an event handler for proximity_in events.
1598 ///
1599 /// The event handler ignores all other events.
1600 #[allow(dead_code)]
1601 pub fn on_proximity_in<F>(f: F) -> ProximityIn<F>
1602 where
1603 F: Fn(&ZwpTabletToolV2Ref, u32, Option<&ZwpTabletV2Ref>, Option<&WlSurfaceRef>),
1604 {
1605 ProximityIn(f)
1606 }
1607
1608 /// Creates an event handler for proximity_out events.
1609 ///
1610 /// The event handler ignores all other events.
1611 #[allow(dead_code)]
1612 pub fn on_proximity_out<F>(f: F) -> ProximityOut<F>
1613 where
1614 F: Fn(&ZwpTabletToolV2Ref),
1615 {
1616 ProximityOut(f)
1617 }
1618
1619 /// Creates an event handler for down events.
1620 ///
1621 /// The event handler ignores all other events.
1622 #[allow(dead_code)]
1623 pub fn on_down<F>(f: F) -> Down<F>
1624 where
1625 F: Fn(&ZwpTabletToolV2Ref, u32),
1626 {
1627 Down(f)
1628 }
1629
1630 /// Creates an event handler for up events.
1631 ///
1632 /// The event handler ignores all other events.
1633 #[allow(dead_code)]
1634 pub fn on_up<F>(f: F) -> Up<F>
1635 where
1636 F: Fn(&ZwpTabletToolV2Ref),
1637 {
1638 Up(f)
1639 }
1640
1641 /// Creates an event handler for motion events.
1642 ///
1643 /// The event handler ignores all other events.
1644 #[allow(dead_code)]
1645 pub fn on_motion<F>(f: F) -> Motion<F>
1646 where
1647 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1648 {
1649 Motion(f)
1650 }
1651
1652 /// Creates an event handler for pressure events.
1653 ///
1654 /// The event handler ignores all other events.
1655 #[allow(dead_code)]
1656 pub fn on_pressure<F>(f: F) -> Pressure<F>
1657 where
1658 F: Fn(&ZwpTabletToolV2Ref, u32),
1659 {
1660 Pressure(f)
1661 }
1662
1663 /// Creates an event handler for distance events.
1664 ///
1665 /// The event handler ignores all other events.
1666 #[allow(dead_code)]
1667 pub fn on_distance<F>(f: F) -> Distance<F>
1668 where
1669 F: Fn(&ZwpTabletToolV2Ref, u32),
1670 {
1671 Distance(f)
1672 }
1673
1674 /// Creates an event handler for tilt events.
1675 ///
1676 /// The event handler ignores all other events.
1677 #[allow(dead_code)]
1678 pub fn on_tilt<F>(f: F) -> Tilt<F>
1679 where
1680 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1681 {
1682 Tilt(f)
1683 }
1684
1685 /// Creates an event handler for rotation events.
1686 ///
1687 /// The event handler ignores all other events.
1688 #[allow(dead_code)]
1689 pub fn on_rotation<F>(f: F) -> Rotation<F>
1690 where
1691 F: Fn(&ZwpTabletToolV2Ref, Fixed),
1692 {
1693 Rotation(f)
1694 }
1695
1696 /// Creates an event handler for slider events.
1697 ///
1698 /// The event handler ignores all other events.
1699 #[allow(dead_code)]
1700 pub fn on_slider<F>(f: F) -> Slider<F>
1701 where
1702 F: Fn(&ZwpTabletToolV2Ref, i32),
1703 {
1704 Slider(f)
1705 }
1706
1707 /// Creates an event handler for wheel events.
1708 ///
1709 /// The event handler ignores all other events.
1710 #[allow(dead_code)]
1711 pub fn on_wheel<F>(f: F) -> Wheel<F>
1712 where
1713 F: Fn(&ZwpTabletToolV2Ref, Fixed, i32),
1714 {
1715 Wheel(f)
1716 }
1717
1718 /// Creates an event handler for button events.
1719 ///
1720 /// The event handler ignores all other events.
1721 #[allow(dead_code)]
1722 pub fn on_button<F>(f: F) -> Button<F>
1723 where
1724 F: Fn(&ZwpTabletToolV2Ref, u32, u32, ZwpTabletToolV2ButtonState),
1725 {
1726 Button(f)
1727 }
1728
1729 /// Creates an event handler for frame events.
1730 ///
1731 /// The event handler ignores all other events.
1732 #[allow(dead_code)]
1733 pub fn on_frame<F>(f: F) -> Frame<F>
1734 where
1735 F: Fn(&ZwpTabletToolV2Ref, u32),
1736 {
1737 Frame(f)
1738 }
1739 }
1740}