Skip to main content

get_registry/common/protocols/tablet_v2/
zwp_tablet_pad_v2.rs

1//! a set of buttons, rings and strips
2//!
3//! A pad device is a set of buttons, rings and strips
4//! usually physically present on the tablet device itself. Some
5//! exceptions exist where the pad device is physically detached, e.g. the
6//! Wacom ExpressKey Remote.
7//!
8//! Pad devices have no axes that control the cursor and are generally
9//! auxiliary devices to the tool devices used on the tablet surface.
10//!
11//! A pad device has a number of static characteristics, e.g. the number
12//! of rings. These capabilities are sent in an event sequence after the
13//! wp_tablet_seat.pad_added event before any actual events from this pad.
14//! This initial event sequence is terminated by a wp_tablet_pad.done
15//! event.
16//!
17//! All pad features (buttons, rings and strips) are logically divided into
18//! groups and all pads have at least one group. The available groups are
19//! notified through the wp_tablet_pad.group event; the compositor will
20//! emit one event per group before emitting wp_tablet_pad.done.
21//!
22//! Groups may have multiple modes. Modes allow clients to map multiple
23//! actions to a single pad feature. Only one mode can be active per group,
24//! although different groups may have different active modes.
25
26use super::super::all_types::*;
27use ::wl_client::builder::prelude::*;
28
29static INTERFACE: wl_interface = wl_interface {
30    name: c"zwp_tablet_pad_v2".as_ptr(),
31    version: 1,
32    method_count: 2,
33    methods: {
34        static MESSAGES: [wl_message; 2] = [
35            wl_message {
36                name: c"set_feedback".as_ptr(),
37                signature: c"usu".as_ptr(),
38                types: {
39                    static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
40                    TYPES.as_ptr().cast()
41                },
42            },
43            wl_message {
44                name: c"destroy".as_ptr(),
45                signature: c"".as_ptr(),
46                types: {
47                    static TYPES: [Option<&'static wl_interface>; 0] = [];
48                    TYPES.as_ptr().cast()
49                },
50            },
51        ];
52        MESSAGES.as_ptr()
53    },
54    event_count: 8,
55    events: {
56        static MESSAGES: [wl_message; 8] = [
57            wl_message {
58                name: c"group".as_ptr(),
59                signature: c"n".as_ptr(),
60                types: {
61                    static TYPES: [Option<&'static wl_interface>; 1] =
62                        [Some(ZwpTabletPadGroupV2::WL_INTERFACE)];
63                    TYPES.as_ptr().cast()
64                },
65            },
66            wl_message {
67                name: c"path".as_ptr(),
68                signature: c"s".as_ptr(),
69                types: {
70                    static TYPES: [Option<&'static wl_interface>; 1] = [None];
71                    TYPES.as_ptr().cast()
72                },
73            },
74            wl_message {
75                name: c"buttons".as_ptr(),
76                signature: c"u".as_ptr(),
77                types: {
78                    static TYPES: [Option<&'static wl_interface>; 1] = [None];
79                    TYPES.as_ptr().cast()
80                },
81            },
82            wl_message {
83                name: c"done".as_ptr(),
84                signature: c"".as_ptr(),
85                types: {
86                    static TYPES: [Option<&'static wl_interface>; 0] = [];
87                    TYPES.as_ptr().cast()
88                },
89            },
90            wl_message {
91                name: c"button".as_ptr(),
92                signature: c"uuu".as_ptr(),
93                types: {
94                    static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
95                    TYPES.as_ptr().cast()
96                },
97            },
98            wl_message {
99                name: c"enter".as_ptr(),
100                signature: c"uoo".as_ptr(),
101                types: {
102                    static TYPES: [Option<&'static wl_interface>; 3] = [
103                        None,
104                        Some(ZwpTabletV2::WL_INTERFACE),
105                        Some(WlSurface::WL_INTERFACE),
106                    ];
107                    TYPES.as_ptr().cast()
108                },
109            },
110            wl_message {
111                name: c"leave".as_ptr(),
112                signature: c"uo".as_ptr(),
113                types: {
114                    static TYPES: [Option<&'static wl_interface>; 2] =
115                        [None, Some(WlSurface::WL_INTERFACE)];
116                    TYPES.as_ptr().cast()
117                },
118            },
119            wl_message {
120                name: c"removed".as_ptr(),
121                signature: c"".as_ptr(),
122                types: {
123                    static TYPES: [Option<&'static wl_interface>; 0] = [];
124                    TYPES.as_ptr().cast()
125                },
126            },
127        ];
128        MESSAGES.as_ptr()
129    },
130};
131
132/// An owned zwp_tablet_pad_v2 proxy.
133///
134/// See the documentation of [the module][self] for the interface description.
135#[derive(Clone, Eq, PartialEq)]
136#[repr(transparent)]
137pub struct ZwpTabletPadV2 {
138    /// This proxy has the interface INTERFACE.
139    proxy: UntypedOwnedProxy,
140}
141
142/// A borrowed zwp_tablet_pad_v2 proxy.
143///
144/// See the documentation of [the module][self] for the interface description.
145#[derive(Eq, PartialEq)]
146#[repr(transparent)]
147pub struct ZwpTabletPadV2Ref {
148    /// This proxy has the interface INTERFACE.
149    proxy: UntypedBorrowedProxy,
150}
151
152// SAFETY: ZwpTabletPadV2 is a transparent wrapper around UntypedOwnedProxy
153unsafe impl UntypedOwnedProxyWrapper for ZwpTabletPadV2 {}
154
155// SAFETY: - INTERFACE is a valid wl_interface
156//         - The only invariant is that self.proxy has a compatible interface
157unsafe impl OwnedProxy for ZwpTabletPadV2 {
158    const INTERFACE: &'static str = "zwp_tablet_pad_v2";
159    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
160    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
161        private::EventHandler(private::NoOpEventHandler);
162    const MAX_VERSION: u32 = 1;
163
164    type Borrowed = ZwpTabletPadV2Ref;
165    type Api = private::ProxyApi;
166    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
167}
168
169// SAFETY: ZwpTabletPadV2Ref is a transparent wrapper around UntypedBorrowedProxy
170unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletPadV2Ref {}
171
172// SAFETY: - The only invariant is that self.proxy has a compatible interface
173unsafe impl BorrowedProxy for ZwpTabletPadV2Ref {
174    type Owned = ZwpTabletPadV2;
175}
176
177impl Deref for ZwpTabletPadV2 {
178    type Target = ZwpTabletPadV2Ref;
179
180    fn deref(&self) -> &Self::Target {
181        proxy::low_level::deref(self)
182    }
183}
184
185mod private {
186    pub struct ProxyApi;
187
188    #[allow(dead_code)]
189    pub struct EventHandler<H>(pub(super) H);
190
191    #[allow(dead_code)]
192    pub struct NoOpEventHandler;
193}
194
195impl Debug for ZwpTabletPadV2 {
196    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
197        write!(f, "zwp_tablet_pad_v2#{}", self.proxy.id())
198    }
199}
200
201impl Debug for ZwpTabletPadV2Ref {
202    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
203        write!(f, "zwp_tablet_pad_v2#{}", self.proxy.id())
204    }
205}
206
207impl PartialEq<ZwpTabletPadV2Ref> for ZwpTabletPadV2 {
208    fn eq(&self, other: &ZwpTabletPadV2Ref) -> bool {
209        self.proxy == other.proxy
210    }
211}
212
213impl PartialEq<ZwpTabletPadV2> for ZwpTabletPadV2Ref {
214    fn eq(&self, other: &ZwpTabletPadV2) -> bool {
215        self.proxy == other.proxy
216    }
217}
218
219#[allow(dead_code)]
220impl ZwpTabletPadV2 {
221    /// Since when the set_feedback request is available.
222    #[allow(dead_code)]
223    pub const REQ__SET_FEEDBACK__SINCE: u32 = 1;
224
225    /// Since when the destroy request is available.
226    #[allow(dead_code)]
227    pub const REQ__DESTROY__SINCE: u32 = 1;
228}
229
230#[allow(dead_code)]
231impl ZwpTabletPadV2 {
232    /// destroy the pad object
233    ///
234    /// Destroy the wp_tablet_pad object. Objects created from this object
235    /// are unaffected and should be destroyed separately.
236    #[inline]
237    pub fn destroy(&self) {
238        let mut args = [];
239        // SAFETY: - self.proxy has the interface INTERFACE
240        //         - 1 < INTERFACE.method_count = 2
241        //         - the request signature is ``
242        unsafe {
243            self.proxy.send_destructor(1, &mut args);
244        }
245    }
246}
247
248#[allow(dead_code)]
249impl ZwpTabletPadV2Ref {
250    /// set compositor feedback
251    ///
252    /// Requests the compositor to use the provided feedback string
253    /// associated with this button. This request should be issued immediately
254    /// after a wp_tablet_pad_group.mode_switch event from the corresponding
255    /// group is received, or whenever a button is mapped to a different
256    /// action. See wp_tablet_pad_group.mode_switch for more details.
257    ///
258    /// Clients are encouraged to provide context-aware descriptions for
259    /// the actions associated with each button, and compositors may use
260    /// this information to offer visual feedback on the button layout
261    /// (e.g. on-screen displays).
262    ///
263    /// Button indices start at 0. Setting the feedback string on a button
264    /// that is reserved by the compositor (i.e. not belonging to any
265    /// wp_tablet_pad_group) does not generate an error but the compositor
266    /// is free to ignore the request.
267    ///
268    /// The provided string 'description' is a UTF-8 encoded string to be
269    /// associated with this ring, and is considered user-visible; general
270    /// internationalization rules apply.
271    ///
272    /// The serial argument will be that of the last
273    /// wp_tablet_pad_group.mode_switch event received for the group of this
274    /// button. Requests providing other serials than the most recent one will
275    /// be ignored.
276    ///
277    /// # Arguments
278    ///
279    /// - `button`: button index
280    /// - `description`: button description
281    /// - `serial`: serial of the mode switch event
282    #[inline]
283    pub fn set_feedback(&self, button: u32, description: &str, serial: u32) {
284        let (arg0, arg1, arg2) = (button, description, serial);
285        with_cstr_cache(|cache| {
286            let str1_offset = cache.len();
287            cache.extend_from_slice(arg1.as_bytes());
288            cache.push(0);
289            let str1 = cache[str1_offset..].as_ptr().cast();
290            let mut args = [
291                wl_argument { u: arg0 },
292                wl_argument { s: str1 },
293                wl_argument { u: arg2 },
294            ];
295            // SAFETY: - self.proxy has the interface INTERFACE
296            //         - 0 < INTERFACE.method_count = 2
297            //         - the request signature is `usu`
298            unsafe {
299                self.proxy.send_request(0, &mut args);
300            }
301        })
302    }
303}
304
305impl ZwpTabletPadV2 {
306    /// Since when the group event is available.
307    #[allow(dead_code)]
308    pub const EVT__GROUP__SINCE: u32 = 1;
309
310    /// Since when the path event is available.
311    #[allow(dead_code)]
312    pub const EVT__PATH__SINCE: u32 = 1;
313
314    /// Since when the buttons event is available.
315    #[allow(dead_code)]
316    pub const EVT__BUTTONS__SINCE: u32 = 1;
317
318    /// Since when the done event is available.
319    #[allow(dead_code)]
320    pub const EVT__DONE__SINCE: u32 = 1;
321
322    /// Since when the button event is available.
323    #[allow(dead_code)]
324    pub const EVT__BUTTON__SINCE: u32 = 1;
325
326    /// Since when the enter event is available.
327    #[allow(dead_code)]
328    pub const EVT__ENTER__SINCE: u32 = 1;
329
330    /// Since when the leave event is available.
331    #[allow(dead_code)]
332    pub const EVT__LEAVE__SINCE: u32 = 1;
333
334    /// Since when the removed event is available.
335    #[allow(dead_code)]
336    pub const EVT__REMOVED__SINCE: u32 = 1;
337}
338
339/// An event handler for [ZwpTabletPadV2] proxies.
340#[allow(dead_code)]
341pub trait ZwpTabletPadV2EventHandler {
342    /// group announced
343    ///
344    /// Sent on wp_tablet_pad initialization to announce available groups.
345    /// One event is sent for each pad group available.
346    ///
347    /// This event is sent in the initial burst of events before the
348    /// wp_tablet_pad.done event. At least one group will be announced.
349    ///
350    /// # Arguments
351    ///
352    /// - `pad_group`:
353    #[inline]
354    fn group(&self, _slf: &ZwpTabletPadV2Ref, pad_group: ZwpTabletPadGroupV2) {
355        let _ = pad_group;
356    }
357
358    /// path to the device
359    ///
360    /// A system-specific device path that indicates which device is behind
361    /// this wp_tablet_pad. This information may be used to gather additional
362    /// information about the device, e.g. through libwacom.
363    ///
364    /// The format of the path is unspecified, it may be a device node, a
365    /// sysfs path, or some other identifier. It is up to the client to
366    /// identify the string provided.
367    ///
368    /// This event is sent in the initial burst of events before the
369    /// wp_tablet_pad.done event.
370    ///
371    /// # Arguments
372    ///
373    /// - `path`: path to local device
374    #[inline]
375    fn path(&self, _slf: &ZwpTabletPadV2Ref, path: &str) {
376        let _ = path;
377    }
378
379    /// buttons announced
380    ///
381    /// Sent on wp_tablet_pad initialization to announce the available
382    /// buttons.
383    ///
384    /// This event is sent in the initial burst of events before the
385    /// wp_tablet_pad.done event. This event is only sent when at least one
386    /// button is available.
387    ///
388    /// # Arguments
389    ///
390    /// - `buttons`: the number of buttons
391    #[inline]
392    fn buttons(&self, _slf: &ZwpTabletPadV2Ref, buttons: u32) {
393        let _ = buttons;
394    }
395
396    /// pad description event sequence complete
397    ///
398    /// This event signals the end of the initial burst of descriptive
399    /// events. A client may consider the static description of the pad to
400    /// be complete and finalize initialization of the pad.
401    #[inline]
402    fn done(&self, _slf: &ZwpTabletPadV2Ref) {}
403
404    /// physical button state
405    ///
406    /// Sent whenever the physical state of a button changes.
407    ///
408    /// # Arguments
409    ///
410    /// - `time`: the time of the event with millisecond granularity
411    /// - `button`: the index of the button that changed state
412    /// - `state`:
413    #[inline]
414    fn button(
415        &self,
416        _slf: &ZwpTabletPadV2Ref,
417        time: u32,
418        button: u32,
419        state: ZwpTabletPadV2ButtonState,
420    ) {
421        let _ = time;
422        let _ = button;
423        let _ = state;
424    }
425
426    /// enter event
427    ///
428    /// Notification that this pad is focused on the specified surface.
429    ///
430    /// # Arguments
431    ///
432    /// - `serial`: serial number of the enter event
433    /// - `tablet`: the tablet the pad is attached to
434    /// - `surface`: surface the pad is focused on
435    ///
436    /// All borrowed proxies passed to this function are guaranteed to be
437    /// immutable and non-null.
438    #[inline]
439    fn enter(
440        &self,
441        _slf: &ZwpTabletPadV2Ref,
442        serial: u32,
443        tablet: Option<&ZwpTabletV2Ref>,
444        surface: Option<&WlSurfaceRef>,
445    ) {
446        let _ = serial;
447        let _ = tablet;
448        let _ = surface;
449    }
450
451    /// leave event
452    ///
453    /// Notification that this pad is no longer focused on the specified
454    /// surface.
455    ///
456    /// # Arguments
457    ///
458    /// - `serial`: serial number of the leave event
459    /// - `surface`: surface the pad is no longer focused on
460    ///
461    /// All borrowed proxies passed to this function are guaranteed to be
462    /// immutable and non-null.
463    #[inline]
464    fn leave(&self, _slf: &ZwpTabletPadV2Ref, serial: u32, surface: Option<&WlSurfaceRef>) {
465        let _ = serial;
466        let _ = surface;
467    }
468
469    /// pad removed event
470    ///
471    /// Sent when the pad has been removed from the system. When a tablet
472    /// is removed its pad(s) will be removed too.
473    ///
474    /// When this event is received, the client must destroy all rings, strips
475    /// and groups that were offered by this pad, and issue wp_tablet_pad.destroy
476    /// the pad itself.
477    #[inline]
478    fn removed(&self, _slf: &ZwpTabletPadV2Ref) {}
479}
480
481impl ZwpTabletPadV2EventHandler for private::NoOpEventHandler {}
482
483// SAFETY: - INTERFACE is a valid wl_interface
484unsafe impl<H> EventHandler for private::EventHandler<H>
485where
486    H: ZwpTabletPadV2EventHandler,
487{
488    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
489
490    #[allow(unused_variables)]
491    unsafe fn handle_event(
492        &self,
493        queue: &Queue,
494        data: *mut u8,
495        slf: &UntypedBorrowedProxy,
496        opcode: u32,
497        args: *mut wl_argument,
498    ) {
499        // SAFETY: This function requires that slf has the interface INTERFACE
500        let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletPadV2Ref>(slf) };
501        match opcode {
502            0 => {
503                // SAFETY: INTERFACE requires that there are 1 arguments
504                let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
505                // SAFETY: - INTERFACE requires that args[0] contains an object
506                //         - ownership is transferred to this function
507                //         - INTERFACE requires that the object has the interface ZwpTabletPadGroupV2::WL_INTERFACE
508                let arg0 = unsafe {
509                    UntypedOwnedProxy::from_plain_wl_proxy(
510                        queue,
511                        NonNull::new_unchecked(args[0].o.cast()),
512                        ZwpTabletPadGroupV2::WL_INTERFACE,
513                    )
514                };
515                // SAFETY: - INTERFACE requires that the object has the interface ZwpTabletPadGroupV2::WL_INTERFACE
516                let arg0 =
517                    unsafe { proxy::low_level::from_untyped_owned::<ZwpTabletPadGroupV2>(arg0) };
518                self.0.group(slf, arg0);
519            }
520            1 => {
521                // SAFETY: INTERFACE requires that there are 1 arguments
522                let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
523                // SAFETY: - INTERFACE requires that args[0] contains a string
524                //         - if the pointer is not null, then it is a c string
525                let arg0 = unsafe { convert_string_arg("zwp_tablet_pad_v2", "path", args[0].s) };
526                self.0.path(slf, arg0);
527            }
528            2 => {
529                // SAFETY: INTERFACE requires that there are 1 arguments
530                let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
531                // SAFETY: - INTERFACE requires that args[0] contains a uint
532                let arg0 = unsafe { args[0].u };
533                self.0.buttons(slf, arg0);
534            }
535            3 => {
536                self.0.done(slf);
537            }
538            4 => {
539                // SAFETY: INTERFACE requires that there are 3 arguments
540                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
541                // SAFETY: - INTERFACE requires that args[0] contains a uint
542                let arg0 = unsafe { args[0].u };
543                // SAFETY: - INTERFACE requires that args[1] contains a uint
544                let arg1 = unsafe { args[1].u };
545                // SAFETY: - INTERFACE requires that args[2] contains a uint
546                let arg2 = unsafe { ZwpTabletPadV2ButtonState(args[2].u) };
547                self.0.button(slf, arg0, arg1, arg2);
548            }
549            5 => {
550                // SAFETY: INTERFACE requires that there are 3 arguments
551                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
552                // SAFETY: - INTERFACE requires that args[0] contains a uint
553                let arg0 = unsafe { args[0].u };
554                // SAFETY: - INTERFACE requires that args[1] contains an object
555                let arg1 = unsafe {
556                    if let Some(p) = NonNull::new(args[1].o.cast()) {
557                        Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
558                    } else {
559                        None
560                    }
561                };
562                // SAFETY: - INTERFACE requires that the object has the interface ZwpTabletV2::WL_INTERFACE
563                let arg1 = arg1.as_ref().map(|arg1| unsafe {
564                    proxy::low_level::from_untyped_borrowed::<ZwpTabletV2Ref>(arg1)
565                });
566                // SAFETY: - INTERFACE requires that args[2] contains an object
567                let arg2 = unsafe {
568                    if let Some(p) = NonNull::new(args[2].o.cast()) {
569                        Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
570                    } else {
571                        None
572                    }
573                };
574                // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
575                let arg2 = arg2.as_ref().map(|arg2| unsafe {
576                    proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg2)
577                });
578                self.0.enter(slf, arg0, arg1, arg2);
579            }
580            6 => {
581                // SAFETY: INTERFACE requires that there are 2 arguments
582                let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
583                // SAFETY: - INTERFACE requires that args[0] contains a uint
584                let arg0 = unsafe { args[0].u };
585                // SAFETY: - INTERFACE requires that args[1] contains an object
586                let arg1 = unsafe {
587                    if let Some(p) = NonNull::new(args[1].o.cast()) {
588                        Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
589                    } else {
590                        None
591                    }
592                };
593                // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
594                let arg1 = arg1.as_ref().map(|arg1| unsafe {
595                    proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg1)
596                });
597                self.0.leave(slf, arg0, arg1);
598            }
599            7 => {
600                self.0.removed(slf);
601            }
602            _ => {
603                invalid_opcode("zwp_tablet_pad_v2", opcode);
604            }
605        }
606    }
607}
608
609impl<H> CreateEventHandler<H> for private::ProxyApi
610where
611    H: ZwpTabletPadV2EventHandler,
612{
613    type EventHandler = private::EventHandler<H>;
614
615    #[inline]
616    fn create_event_handler(handler: H) -> Self::EventHandler {
617        private::EventHandler(handler)
618    }
619}
620
621impl ZwpTabletPadV2 {
622    /// Since when the button_state.released enum variant is available.
623    #[allow(dead_code)]
624    pub const ENM__BUTTON_STATE_RELEASED__SINCE: u32 = 1;
625    /// Since when the button_state.pressed enum variant is available.
626    #[allow(dead_code)]
627    pub const ENM__BUTTON_STATE_PRESSED__SINCE: u32 = 1;
628}
629
630/// physical button state
631///
632/// Describes the physical state of a button that caused the button
633/// event.
634#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
635#[allow(dead_code)]
636pub struct ZwpTabletPadV2ButtonState(pub u32);
637
638impl ZwpTabletPadV2ButtonState {
639    /// the button is not pressed
640    #[allow(dead_code)]
641    pub const RELEASED: Self = Self(0);
642
643    /// the button is pressed
644    #[allow(dead_code)]
645    pub const PRESSED: Self = Self(1);
646}
647
648impl Debug for ZwpTabletPadV2ButtonState {
649    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
650        let name = match *self {
651            Self::RELEASED => "RELEASED",
652            Self::PRESSED => "PRESSED",
653            _ => return Debug::fmt(&self.0, f),
654        };
655        f.write_str(name)
656    }
657}
658
659/// Functional event handlers.
660pub mod event_handlers {
661    use super::*;
662
663    /// Event handler for group events.
664    pub struct Group<F>(F);
665    impl<F> ZwpTabletPadV2EventHandler for Group<F>
666    where
667        F: Fn(&ZwpTabletPadV2Ref, ZwpTabletPadGroupV2),
668    {
669        #[inline]
670        fn group(&self, _slf: &ZwpTabletPadV2Ref, pad_group: ZwpTabletPadGroupV2) {
671            self.0(_slf, pad_group)
672        }
673    }
674
675    /// Event handler for path events.
676    pub struct Path<F>(F);
677    impl<F> ZwpTabletPadV2EventHandler for Path<F>
678    where
679        F: Fn(&ZwpTabletPadV2Ref, &str),
680    {
681        #[inline]
682        fn path(&self, _slf: &ZwpTabletPadV2Ref, path: &str) {
683            self.0(_slf, path)
684        }
685    }
686
687    /// Event handler for buttons events.
688    pub struct Buttons<F>(F);
689    impl<F> ZwpTabletPadV2EventHandler for Buttons<F>
690    where
691        F: Fn(&ZwpTabletPadV2Ref, u32),
692    {
693        #[inline]
694        fn buttons(&self, _slf: &ZwpTabletPadV2Ref, buttons: u32) {
695            self.0(_slf, buttons)
696        }
697    }
698
699    /// Event handler for done events.
700    pub struct Done<F>(F);
701    impl<F> ZwpTabletPadV2EventHandler for Done<F>
702    where
703        F: Fn(&ZwpTabletPadV2Ref),
704    {
705        #[inline]
706        fn done(&self, _slf: &ZwpTabletPadV2Ref) {
707            self.0(_slf)
708        }
709    }
710
711    /// Event handler for button events.
712    pub struct Button<F>(F);
713    impl<F> ZwpTabletPadV2EventHandler for Button<F>
714    where
715        F: Fn(&ZwpTabletPadV2Ref, u32, u32, ZwpTabletPadV2ButtonState),
716    {
717        #[inline]
718        fn button(
719            &self,
720            _slf: &ZwpTabletPadV2Ref,
721            time: u32,
722            button: u32,
723            state: ZwpTabletPadV2ButtonState,
724        ) {
725            self.0(_slf, time, button, state)
726        }
727    }
728
729    /// Event handler for enter events.
730    pub struct Enter<F>(F);
731    impl<F> ZwpTabletPadV2EventHandler for Enter<F>
732    where
733        F: Fn(&ZwpTabletPadV2Ref, u32, Option<&ZwpTabletV2Ref>, Option<&WlSurfaceRef>),
734    {
735        #[inline]
736        fn enter(
737            &self,
738            _slf: &ZwpTabletPadV2Ref,
739            serial: u32,
740            tablet: Option<&ZwpTabletV2Ref>,
741            surface: Option<&WlSurfaceRef>,
742        ) {
743            self.0(_slf, serial, tablet, surface)
744        }
745    }
746
747    /// Event handler for leave events.
748    pub struct Leave<F>(F);
749    impl<F> ZwpTabletPadV2EventHandler for Leave<F>
750    where
751        F: Fn(&ZwpTabletPadV2Ref, u32, Option<&WlSurfaceRef>),
752    {
753        #[inline]
754        fn leave(&self, _slf: &ZwpTabletPadV2Ref, serial: u32, surface: Option<&WlSurfaceRef>) {
755            self.0(_slf, serial, surface)
756        }
757    }
758
759    /// Event handler for removed events.
760    pub struct Removed<F>(F);
761    impl<F> ZwpTabletPadV2EventHandler for Removed<F>
762    where
763        F: Fn(&ZwpTabletPadV2Ref),
764    {
765        #[inline]
766        fn removed(&self, _slf: &ZwpTabletPadV2Ref) {
767            self.0(_slf)
768        }
769    }
770
771    impl ZwpTabletPadV2 {
772        /// Creates an event handler for group events.
773        ///
774        /// The event handler ignores all other events.
775        #[allow(dead_code)]
776        pub fn on_group<F>(f: F) -> Group<F>
777        where
778            F: Fn(&ZwpTabletPadV2Ref, ZwpTabletPadGroupV2),
779        {
780            Group(f)
781        }
782
783        /// Creates an event handler for path events.
784        ///
785        /// The event handler ignores all other events.
786        #[allow(dead_code)]
787        pub fn on_path<F>(f: F) -> Path<F>
788        where
789            F: Fn(&ZwpTabletPadV2Ref, &str),
790        {
791            Path(f)
792        }
793
794        /// Creates an event handler for buttons events.
795        ///
796        /// The event handler ignores all other events.
797        #[allow(dead_code)]
798        pub fn on_buttons<F>(f: F) -> Buttons<F>
799        where
800            F: Fn(&ZwpTabletPadV2Ref, u32),
801        {
802            Buttons(f)
803        }
804
805        /// Creates an event handler for done events.
806        ///
807        /// The event handler ignores all other events.
808        #[allow(dead_code)]
809        pub fn on_done<F>(f: F) -> Done<F>
810        where
811            F: Fn(&ZwpTabletPadV2Ref),
812        {
813            Done(f)
814        }
815
816        /// Creates an event handler for button events.
817        ///
818        /// The event handler ignores all other events.
819        #[allow(dead_code)]
820        pub fn on_button<F>(f: F) -> Button<F>
821        where
822            F: Fn(&ZwpTabletPadV2Ref, u32, u32, ZwpTabletPadV2ButtonState),
823        {
824            Button(f)
825        }
826
827        /// Creates an event handler for enter events.
828        ///
829        /// The event handler ignores all other events.
830        #[allow(dead_code)]
831        pub fn on_enter<F>(f: F) -> Enter<F>
832        where
833            F: Fn(&ZwpTabletPadV2Ref, u32, Option<&ZwpTabletV2Ref>, Option<&WlSurfaceRef>),
834        {
835            Enter(f)
836        }
837
838        /// Creates an event handler for leave events.
839        ///
840        /// The event handler ignores all other events.
841        #[allow(dead_code)]
842        pub fn on_leave<F>(f: F) -> Leave<F>
843        where
844            F: Fn(&ZwpTabletPadV2Ref, u32, Option<&WlSurfaceRef>),
845        {
846            Leave(f)
847        }
848
849        /// Creates an event handler for removed events.
850        ///
851        /// The event handler ignores all other events.
852        #[allow(dead_code)]
853        pub fn on_removed<F>(f: F) -> Removed<F>
854        where
855            F: Fn(&ZwpTabletPadV2Ref),
856        {
857            Removed(f)
858        }
859    }
860}