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