Skip to main content

get_registry/common/protocols_data/wayland/
wl_pointer.rs

1//! pointer input device
2//!
3//! The wl_pointer interface represents one or more input devices,
4//! such as mice, which control the pointer location and pointer_focus
5//! of a seat.
6//!
7//! The wl_pointer interface generates motion, enter and leave
8//! events for the surfaces that the pointer is located over,
9//! and button and axis events for button presses, button releases
10//! and scrolling.
11
12use super::super::all_types::*;
13use ::wl_client::builder::prelude::*;
14
15static INTERFACE: wl_interface = wl_interface {
16    name: c"wl_pointer".as_ptr(),
17    version: 10,
18    method_count: 2,
19    methods: {
20        static MESSAGES: [wl_message; 2] = [
21            wl_message {
22                name: c"set_cursor".as_ptr(),
23                signature: c"u?oii".as_ptr(),
24                types: {
25                    static TYPES: [Option<&'static wl_interface>; 4] =
26                        [None, Some(WlSurface::WL_INTERFACE), None, None];
27                    TYPES.as_ptr().cast()
28                },
29            },
30            wl_message {
31                name: c"release".as_ptr(),
32                signature: c"".as_ptr(),
33                types: {
34                    static TYPES: [Option<&'static wl_interface>; 0] = [];
35                    TYPES.as_ptr().cast()
36                },
37            },
38        ];
39        MESSAGES.as_ptr()
40    },
41    event_count: 11,
42    events: {
43        static MESSAGES: [wl_message; 11] = [
44            wl_message {
45                name: c"enter".as_ptr(),
46                signature: c"uoff".as_ptr(),
47                types: {
48                    static TYPES: [Option<&'static wl_interface>; 4] =
49                        [None, Some(WlSurface::WL_INTERFACE), None, None];
50                    TYPES.as_ptr().cast()
51                },
52            },
53            wl_message {
54                name: c"leave".as_ptr(),
55                signature: c"uo".as_ptr(),
56                types: {
57                    static TYPES: [Option<&'static wl_interface>; 2] =
58                        [None, Some(WlSurface::WL_INTERFACE)];
59                    TYPES.as_ptr().cast()
60                },
61            },
62            wl_message {
63                name: c"motion".as_ptr(),
64                signature: c"uff".as_ptr(),
65                types: {
66                    static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
67                    TYPES.as_ptr().cast()
68                },
69            },
70            wl_message {
71                name: c"button".as_ptr(),
72                signature: c"uuuu".as_ptr(),
73                types: {
74                    static TYPES: [Option<&'static wl_interface>; 4] = [None, None, None, None];
75                    TYPES.as_ptr().cast()
76                },
77            },
78            wl_message {
79                name: c"axis".as_ptr(),
80                signature: c"uuf".as_ptr(),
81                types: {
82                    static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
83                    TYPES.as_ptr().cast()
84                },
85            },
86            wl_message {
87                name: c"frame".as_ptr(),
88                signature: c"".as_ptr(),
89                types: {
90                    static TYPES: [Option<&'static wl_interface>; 0] = [];
91                    TYPES.as_ptr().cast()
92                },
93            },
94            wl_message {
95                name: c"axis_source".as_ptr(),
96                signature: c"u".as_ptr(),
97                types: {
98                    static TYPES: [Option<&'static wl_interface>; 1] = [None];
99                    TYPES.as_ptr().cast()
100                },
101            },
102            wl_message {
103                name: c"axis_stop".as_ptr(),
104                signature: c"uu".as_ptr(),
105                types: {
106                    static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
107                    TYPES.as_ptr().cast()
108                },
109            },
110            wl_message {
111                name: c"axis_discrete".as_ptr(),
112                signature: c"ui".as_ptr(),
113                types: {
114                    static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
115                    TYPES.as_ptr().cast()
116                },
117            },
118            wl_message {
119                name: c"axis_value120".as_ptr(),
120                signature: c"ui".as_ptr(),
121                types: {
122                    static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
123                    TYPES.as_ptr().cast()
124                },
125            },
126            wl_message {
127                name: c"axis_relative_direction".as_ptr(),
128                signature: c"uu".as_ptr(),
129                types: {
130                    static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
131                    TYPES.as_ptr().cast()
132                },
133            },
134        ];
135        MESSAGES.as_ptr()
136    },
137};
138
139/// An owned wl_pointer proxy.
140///
141/// See the documentation of [the module][self] for the interface description.
142#[derive(Clone, Eq, PartialEq)]
143#[repr(transparent)]
144pub struct WlPointer {
145    /// This proxy has the interface INTERFACE.
146    proxy: UntypedOwnedProxy,
147}
148
149/// A borrowed wl_pointer proxy.
150///
151/// See the documentation of [the module][self] for the interface description.
152#[derive(Eq, PartialEq)]
153#[repr(transparent)]
154pub struct WlPointerRef {
155    /// This proxy has the interface INTERFACE.
156    proxy: UntypedBorrowedProxy,
157}
158
159// SAFETY: WlPointer is a transparent wrapper around UntypedOwnedProxy
160unsafe impl UntypedOwnedProxyWrapper for WlPointer {}
161
162// SAFETY: - INTERFACE is a valid wl_interface
163//         - The only invariant is that self.proxy has a compatible interface
164unsafe impl OwnedProxy for WlPointer {
165    const INTERFACE: &'static str = "wl_pointer";
166    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
167    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
168        private::EventHandler(private::NoOpEventHandler);
169    const MAX_VERSION: u32 = 10;
170
171    type Borrowed = WlPointerRef;
172    type Api = private::ProxyApi;
173    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
174}
175
176// SAFETY: WlPointerRef is a transparent wrapper around UntypedBorrowedProxy
177unsafe impl UntypedBorrowedProxyWrapper for WlPointerRef {}
178
179// SAFETY: - The only invariant is that self.proxy has a compatible interface
180unsafe impl BorrowedProxy for WlPointerRef {
181    type Owned = WlPointer;
182}
183
184impl Deref for WlPointer {
185    type Target = WlPointerRef;
186
187    fn deref(&self) -> &Self::Target {
188        proxy::low_level::deref(self)
189    }
190}
191
192mod private {
193    pub struct ProxyApi;
194
195    #[allow(dead_code)]
196    pub struct EventHandler<H>(pub(super) H);
197
198    #[allow(dead_code)]
199    pub struct NoOpEventHandler;
200}
201
202impl Debug for WlPointer {
203    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
204        write!(f, "wl_pointer#{}", self.proxy.id())
205    }
206}
207
208impl Debug for WlPointerRef {
209    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
210        write!(f, "wl_pointer#{}", self.proxy.id())
211    }
212}
213
214impl PartialEq<WlPointerRef> for WlPointer {
215    fn eq(&self, other: &WlPointerRef) -> bool {
216        self.proxy == other.proxy
217    }
218}
219
220impl PartialEq<WlPointer> for WlPointerRef {
221    fn eq(&self, other: &WlPointer) -> bool {
222        self.proxy == other.proxy
223    }
224}
225
226#[allow(dead_code)]
227impl WlPointer {
228    /// Since when the set_cursor request is available.
229    #[allow(dead_code)]
230    pub const REQ__SET_CURSOR__SINCE: u32 = 1;
231
232    /// Since when the release request is available.
233    #[allow(dead_code)]
234    pub const REQ__RELEASE__SINCE: u32 = 3;
235}
236
237#[allow(dead_code)]
238impl WlPointer {
239    /// release the pointer object
240    ///
241    /// Using this request a client can tell the server that it is not going to
242    /// use the pointer object anymore.
243    ///
244    /// This request destroys the pointer proxy object, so clients must not call
245    /// wl_pointer_destroy() after using this request.
246    #[inline]
247    pub fn release(&self) {
248        let mut args = [];
249        // SAFETY: - self.proxy has the interface INTERFACE
250        //         - 1 < INTERFACE.method_count = 2
251        //         - the request signature is ``
252        unsafe {
253            self.proxy.send_destructor(1, &mut args);
254        }
255    }
256}
257
258#[allow(dead_code)]
259impl WlPointerRef {
260    /// set the pointer surface
261    ///
262    /// Set the pointer surface, i.e., the surface that contains the
263    /// pointer image (cursor). This request gives the surface the role
264    /// of a cursor. If the surface already has another role, it raises
265    /// a protocol error.
266    ///
267    /// The cursor actually changes only if the pointer
268    /// focus for this device is one of the requesting client's surfaces
269    /// or the surface parameter is the current pointer surface. If
270    /// there was a previous surface set with this request it is
271    /// replaced. If surface is NULL, the pointer image is hidden.
272    ///
273    /// The parameters hotspot_x and hotspot_y define the position of
274    /// the pointer surface relative to the pointer location. Its
275    /// top-left corner is always at (x, y) - (hotspot_x, hotspot_y),
276    /// where (x, y) are the coordinates of the pointer location, in
277    /// surface-local coordinates.
278    ///
279    /// On wl_surface.offset requests to the pointer surface, hotspot_x
280    /// and hotspot_y are decremented by the x and y parameters
281    /// passed to the request. The offset must be applied by
282    /// wl_surface.commit as usual.
283    ///
284    /// The hotspot can also be updated by passing the currently set
285    /// pointer surface to this request with new values for hotspot_x
286    /// and hotspot_y.
287    ///
288    /// The input region is ignored for wl_surfaces with the role of
289    /// a cursor. When the use as a cursor ends, the wl_surface is
290    /// unmapped.
291    ///
292    /// The serial parameter must match the latest wl_pointer.enter
293    /// serial number sent to the client. Otherwise the request will be
294    /// ignored.
295    ///
296    /// # Arguments
297    ///
298    /// - `serial`: serial number of the enter event
299    /// - `surface`: pointer surface
300    /// - `hotspot_x`: surface-local x coordinate
301    /// - `hotspot_y`: surface-local y coordinate
302    #[inline]
303    pub fn set_cursor(
304        &self,
305        serial: u32,
306        surface: Option<&WlSurfaceRef>,
307        hotspot_x: i32,
308        hotspot_y: i32,
309    ) {
310        let (arg0, arg1, arg2, arg3) = (serial, surface, hotspot_x, hotspot_y);
311        let obj1_lock = arg1.map(|arg1| proxy::lock(arg1));
312        let obj1 = obj1_lock
313            .map(|obj1_lock| check_argument_proxy("surface", obj1_lock.wl_proxy()))
314            .unwrap_or(ptr::null_mut());
315        let mut args = [
316            wl_argument { u: arg0 },
317            wl_argument { o: obj1 },
318            wl_argument { i: arg2 },
319            wl_argument { i: arg3 },
320        ];
321        // SAFETY: - self.proxy has the interface INTERFACE
322        //         - 0 < INTERFACE.method_count = 2
323        //         - the request signature is `u?oii`
324        unsafe {
325            self.proxy.send_request(0, &mut args);
326        }
327    }
328}
329
330impl WlPointer {
331    /// Since when the enter event is available.
332    #[allow(dead_code)]
333    pub const EVT__ENTER__SINCE: u32 = 1;
334
335    /// Since when the leave event is available.
336    #[allow(dead_code)]
337    pub const EVT__LEAVE__SINCE: u32 = 1;
338
339    /// Since when the motion event is available.
340    #[allow(dead_code)]
341    pub const EVT__MOTION__SINCE: u32 = 1;
342
343    /// Since when the button event is available.
344    #[allow(dead_code)]
345    pub const EVT__BUTTON__SINCE: u32 = 1;
346
347    /// Since when the axis event is available.
348    #[allow(dead_code)]
349    pub const EVT__AXIS__SINCE: u32 = 1;
350
351    /// Since when the frame event is available.
352    #[allow(dead_code)]
353    pub const EVT__FRAME__SINCE: u32 = 5;
354
355    /// Since when the axis_source event is available.
356    #[allow(dead_code)]
357    pub const EVT__AXIS_SOURCE__SINCE: u32 = 5;
358
359    /// Since when the axis_stop event is available.
360    #[allow(dead_code)]
361    pub const EVT__AXIS_STOP__SINCE: u32 = 5;
362
363    /// Since when the axis_discrete event is available.
364    #[allow(dead_code)]
365    pub const EVT__AXIS_DISCRETE__SINCE: u32 = 5;
366
367    /// Since when the axis_discrete event is deprecated.
368    #[allow(dead_code)]
369    pub const EVT__AXIS_DISCRETE__DEPRECATED_SINCE: u32 = 8;
370
371    /// Since when the axis_value120 event is available.
372    #[allow(dead_code)]
373    pub const EVT__AXIS_VALUE120__SINCE: u32 = 8;
374
375    /// Since when the axis_relative_direction event is available.
376    #[allow(dead_code)]
377    pub const EVT__AXIS_RELATIVE_DIRECTION__SINCE: u32 = 9;
378}
379
380/// An event handler for [WlPointer] proxies.
381#[allow(dead_code)]
382pub trait WlPointerEventHandler {
383    type Data: 'static;
384
385    /// enter event
386    ///
387    /// Notification that this seat's pointer is focused on a certain
388    /// surface.
389    ///
390    /// When a seat's focus enters a surface, the pointer image
391    /// is undefined and a client should respond to this event by setting
392    /// an appropriate pointer image with the set_cursor request.
393    ///
394    /// # Arguments
395    ///
396    /// - `serial`: serial number of the enter event
397    /// - `surface`: surface entered by the pointer
398    /// - `surface_x`: surface-local x coordinate
399    /// - `surface_y`: surface-local y coordinate
400    ///
401    /// All borrowed proxies passed to this function are guaranteed to be
402    /// immutable and non-null.
403    #[inline]
404    fn enter(
405        &self,
406        _data: &mut Self::Data,
407        _slf: &WlPointerRef,
408        serial: u32,
409        surface: Option<&WlSurfaceRef>,
410        surface_x: Fixed,
411        surface_y: Fixed,
412    ) {
413        let _ = serial;
414        let _ = surface;
415        let _ = surface_x;
416        let _ = surface_y;
417    }
418
419    /// leave event
420    ///
421    /// Notification that this seat's pointer is no longer focused on
422    /// a certain surface.
423    ///
424    /// The leave notification is sent before the enter notification
425    /// for the new focus.
426    ///
427    /// # Arguments
428    ///
429    /// - `serial`: serial number of the leave event
430    /// - `surface`: surface left by the pointer
431    ///
432    /// All borrowed proxies passed to this function are guaranteed to be
433    /// immutable and non-null.
434    #[inline]
435    fn leave(
436        &self,
437        _data: &mut Self::Data,
438        _slf: &WlPointerRef,
439        serial: u32,
440        surface: Option<&WlSurfaceRef>,
441    ) {
442        let _ = serial;
443        let _ = surface;
444    }
445
446    /// pointer motion event
447    ///
448    /// Notification of pointer location change. The arguments
449    /// surface_x and surface_y are the location relative to the
450    /// focused surface.
451    ///
452    /// # Arguments
453    ///
454    /// - `time`: timestamp with millisecond granularity
455    /// - `surface_x`: surface-local x coordinate
456    /// - `surface_y`: surface-local y coordinate
457    #[inline]
458    fn motion(
459        &self,
460        _data: &mut Self::Data,
461        _slf: &WlPointerRef,
462        time: u32,
463        surface_x: Fixed,
464        surface_y: Fixed,
465    ) {
466        let _ = time;
467        let _ = surface_x;
468        let _ = surface_y;
469    }
470
471    /// pointer button event
472    ///
473    /// Mouse button click and release notifications.
474    ///
475    /// The location of the click is given by the last motion or
476    /// enter event.
477    /// The time argument is a timestamp with millisecond
478    /// granularity, with an undefined base.
479    ///
480    /// The button is a button code as defined in the Linux kernel's
481    /// linux/input-event-codes.h header file, e.g. BTN_LEFT.
482    ///
483    /// Any 16-bit button code value is reserved for future additions to the
484    /// kernel's event code list. All other button codes above 0xFFFF are
485    /// currently undefined but may be used in future versions of this
486    /// protocol.
487    ///
488    /// # Arguments
489    ///
490    /// - `serial`: serial number of the button event
491    /// - `time`: timestamp with millisecond granularity
492    /// - `button`: button that produced the event
493    /// - `state`: physical state of the button
494    #[inline]
495    fn button(
496        &self,
497        _data: &mut Self::Data,
498        _slf: &WlPointerRef,
499        serial: u32,
500        time: u32,
501        button: u32,
502        state: WlPointerButtonState,
503    ) {
504        let _ = serial;
505        let _ = time;
506        let _ = button;
507        let _ = state;
508    }
509
510    /// axis event
511    ///
512    /// Scroll and other axis notifications.
513    ///
514    /// For scroll events (vertical and horizontal scroll axes), the
515    /// value parameter is the length of a vector along the specified
516    /// axis in a coordinate space identical to those of motion events,
517    /// representing a relative movement along the specified axis.
518    ///
519    /// For devices that support movements non-parallel to axes multiple
520    /// axis events will be emitted.
521    ///
522    /// When applicable, for example for touch pads, the server can
523    /// choose to emit scroll events where the motion vector is
524    /// equivalent to a motion event vector.
525    ///
526    /// When applicable, a client can transform its content relative to the
527    /// scroll distance.
528    ///
529    /// # Arguments
530    ///
531    /// - `time`: timestamp with millisecond granularity
532    /// - `axis`: axis type
533    /// - `value`: length of vector in surface-local coordinate space
534    #[inline]
535    fn axis(
536        &self,
537        _data: &mut Self::Data,
538        _slf: &WlPointerRef,
539        time: u32,
540        axis: WlPointerAxis,
541        value: Fixed,
542    ) {
543        let _ = time;
544        let _ = axis;
545        let _ = value;
546    }
547
548    /// end of a pointer event sequence
549    ///
550    /// Indicates the end of a set of events that logically belong together.
551    /// A client is expected to accumulate the data in all events within the
552    /// frame before proceeding.
553    ///
554    /// All wl_pointer events before a wl_pointer.frame event belong
555    /// logically together. For example, in a diagonal scroll motion the
556    /// compositor will send an optional wl_pointer.axis_source event, two
557    /// wl_pointer.axis events (horizontal and vertical) and finally a
558    /// wl_pointer.frame event. The client may use this information to
559    /// calculate a diagonal vector for scrolling.
560    ///
561    /// When multiple wl_pointer.axis events occur within the same frame,
562    /// the motion vector is the combined motion of all events.
563    /// When a wl_pointer.axis and a wl_pointer.axis_stop event occur within
564    /// the same frame, this indicates that axis movement in one axis has
565    /// stopped but continues in the other axis.
566    /// When multiple wl_pointer.axis_stop events occur within the same
567    /// frame, this indicates that these axes stopped in the same instance.
568    ///
569    /// A wl_pointer.frame event is sent for every logical event group,
570    /// even if the group only contains a single wl_pointer event.
571    /// Specifically, a client may get a sequence: motion, frame, button,
572    /// frame, axis, frame, axis_stop, frame.
573    ///
574    /// The wl_pointer.enter and wl_pointer.leave events are logical events
575    /// generated by the compositor and not the hardware. These events are
576    /// also grouped by a wl_pointer.frame. When a pointer moves from one
577    /// surface to another, a compositor should group the
578    /// wl_pointer.leave event within the same wl_pointer.frame.
579    /// However, a client must not rely on wl_pointer.leave and
580    /// wl_pointer.enter being in the same wl_pointer.frame.
581    /// Compositor-specific policies may require the wl_pointer.leave and
582    /// wl_pointer.enter event being split across multiple wl_pointer.frame
583    /// groups.
584    #[inline]
585    fn frame(&self, _data: &mut Self::Data, _slf: &WlPointerRef) {}
586
587    /// axis source event
588    ///
589    /// Source information for scroll and other axes.
590    ///
591    /// This event does not occur on its own. It is sent before a
592    /// wl_pointer.frame event and carries the source information for
593    /// all events within that frame.
594    ///
595    /// The source specifies how this event was generated. If the source is
596    /// wl_pointer.axis_source.finger, a wl_pointer.axis_stop event will be
597    /// sent when the user lifts the finger off the device.
598    ///
599    /// If the source is wl_pointer.axis_source.wheel,
600    /// wl_pointer.axis_source.wheel_tilt or
601    /// wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event may
602    /// or may not be sent. Whether a compositor sends an axis_stop event
603    /// for these sources is hardware-specific and implementation-dependent;
604    /// clients must not rely on receiving an axis_stop event for these
605    /// scroll sources and should treat scroll sequences from these scroll
606    /// sources as unterminated by default.
607    ///
608    /// This event is optional. If the source is unknown for a particular
609    /// axis event sequence, no event is sent.
610    /// Only one wl_pointer.axis_source event is permitted per frame.
611    ///
612    /// The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
613    /// not guaranteed.
614    ///
615    /// # Arguments
616    ///
617    /// - `axis_source`: source of the axis event
618    #[inline]
619    fn axis_source(
620        &self,
621        _data: &mut Self::Data,
622        _slf: &WlPointerRef,
623        axis_source: WlPointerAxisSource,
624    ) {
625        let _ = axis_source;
626    }
627
628    /// axis stop event
629    ///
630    /// Stop notification for scroll and other axes.
631    ///
632    /// For some wl_pointer.axis_source types, a wl_pointer.axis_stop event
633    /// is sent to notify a client that the axis sequence has terminated.
634    /// This enables the client to implement kinetic scrolling.
635    /// See the wl_pointer.axis_source documentation for information on when
636    /// this event may be generated.
637    ///
638    /// Any wl_pointer.axis events with the same axis_source after this
639    /// event should be considered as the start of a new axis motion.
640    ///
641    /// The timestamp is to be interpreted identical to the timestamp in the
642    /// wl_pointer.axis event. The timestamp value may be the same as a
643    /// preceding wl_pointer.axis event.
644    ///
645    /// # Arguments
646    ///
647    /// - `time`: timestamp with millisecond granularity
648    /// - `axis`: the axis stopped with this event
649    #[inline]
650    fn axis_stop(
651        &self,
652        _data: &mut Self::Data,
653        _slf: &WlPointerRef,
654        time: u32,
655        axis: WlPointerAxis,
656    ) {
657        let _ = time;
658        let _ = axis;
659    }
660
661    /// axis click event
662    ///
663    /// Discrete step information for scroll and other axes.
664    ///
665    /// This event carries the axis value of the wl_pointer.axis event in
666    /// discrete steps (e.g. mouse wheel clicks).
667    ///
668    /// This event is deprecated with wl_pointer version 8 - this event is not
669    /// sent to clients supporting version 8 or later.
670    ///
671    /// This event does not occur on its own, it is coupled with a
672    /// wl_pointer.axis event that represents this axis value on a
673    /// continuous scale. The protocol guarantees that each axis_discrete
674    /// event is always followed by exactly one axis event with the same
675    /// axis number within the same wl_pointer.frame. Note that the protocol
676    /// allows for other events to occur between the axis_discrete and
677    /// its coupled axis event, including other axis_discrete or axis
678    /// events. A wl_pointer.frame must not contain more than one axis_discrete
679    /// event per axis type.
680    ///
681    /// This event is optional; continuous scrolling devices
682    /// like two-finger scrolling on touchpads do not have discrete
683    /// steps and do not generate this event.
684    ///
685    /// The discrete value carries the directional information. e.g. a value
686    /// of -2 is two steps towards the negative direction of this axis.
687    ///
688    /// The axis number is identical to the axis number in the associated
689    /// axis event.
690    ///
691    /// The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
692    /// not guaranteed.
693    ///
694    /// # Arguments
695    ///
696    /// - `axis`: axis type
697    /// - `discrete`: number of steps
698    #[inline]
699    fn axis_discrete(
700        &self,
701        _data: &mut Self::Data,
702        _slf: &WlPointerRef,
703        axis: WlPointerAxis,
704        discrete: i32,
705    ) {
706        let _ = axis;
707        let _ = discrete;
708    }
709
710    /// axis high-resolution scroll event
711    ///
712    /// Discrete high-resolution scroll information.
713    ///
714    /// This event carries high-resolution wheel scroll information,
715    /// with each multiple of 120 representing one logical scroll step
716    /// (a wheel detent). For example, an axis_value120 of 30 is one quarter of
717    /// a logical scroll step in the positive direction, a value120 of
718    /// -240 are two logical scroll steps in the negative direction within the
719    /// same hardware event.
720    /// Clients that rely on discrete scrolling should accumulate the
721    /// value120 to multiples of 120 before processing the event.
722    ///
723    /// The value120 must not be zero.
724    ///
725    /// This event replaces the wl_pointer.axis_discrete event in clients
726    /// supporting wl_pointer version 8 or later.
727    ///
728    /// Where a wl_pointer.axis_source event occurs in the same
729    /// wl_pointer.frame, the axis source applies to this event.
730    ///
731    /// The order of wl_pointer.axis_value120 and wl_pointer.axis_source is
732    /// not guaranteed.
733    ///
734    /// # Arguments
735    ///
736    /// - `axis`: axis type
737    /// - `value120`: scroll distance as fraction of 120
738    #[inline]
739    fn axis_value120(
740        &self,
741        _data: &mut Self::Data,
742        _slf: &WlPointerRef,
743        axis: WlPointerAxis,
744        value120: i32,
745    ) {
746        let _ = axis;
747        let _ = value120;
748    }
749
750    /// axis relative physical direction event
751    ///
752    /// Relative directional information of the entity causing the axis
753    /// motion.
754    ///
755    /// For a wl_pointer.axis event, the wl_pointer.axis_relative_direction
756    /// event specifies the movement direction of the entity causing the
757    /// wl_pointer.axis event. For example:
758    /// - if a user's fingers on a touchpad move down and this
759    ///   causes a wl_pointer.axis vertical_scroll down event, the physical
760    ///   direction is 'identical'
761    /// - if a user's fingers on a touchpad move down and this causes a
762    ///   wl_pointer.axis vertical_scroll up scroll up event ('natural
763    ///   scrolling'), the physical direction is 'inverted'.
764    ///
765    /// A client may use this information to adjust scroll motion of
766    /// components. Specifically, enabling natural scrolling causes the
767    /// content to change direction compared to traditional scrolling.
768    /// Some widgets like volume control sliders should usually match the
769    /// physical direction regardless of whether natural scrolling is
770    /// active. This event enables clients to match the scroll direction of
771    /// a widget to the physical direction.
772    ///
773    /// This event does not occur on its own, it is coupled with a
774    /// wl_pointer.axis event that represents this axis value.
775    /// The protocol guarantees that each axis_relative_direction event is
776    /// always followed by exactly one axis event with the same
777    /// axis number within the same wl_pointer.frame. Note that the protocol
778    /// allows for other events to occur between the axis_relative_direction
779    /// and its coupled axis event.
780    ///
781    /// The axis number is identical to the axis number in the associated
782    /// axis event.
783    ///
784    /// The order of wl_pointer.axis_relative_direction,
785    /// wl_pointer.axis_discrete and wl_pointer.axis_source is not
786    /// guaranteed.
787    ///
788    /// # Arguments
789    ///
790    /// - `axis`: axis type
791    /// - `direction`: physical direction relative to axis motion
792    #[inline]
793    fn axis_relative_direction(
794        &self,
795        _data: &mut Self::Data,
796        _slf: &WlPointerRef,
797        axis: WlPointerAxis,
798        direction: WlPointerAxisRelativeDirection,
799    ) {
800        let _ = axis;
801        let _ = direction;
802    }
803}
804
805impl WlPointerEventHandler for private::NoOpEventHandler {
806    type Data = ();
807}
808
809// SAFETY: - INTERFACE is a valid wl_interface
810//         - mutable_type always returns the same value
811unsafe impl<H> EventHandler for private::EventHandler<H>
812where
813    H: WlPointerEventHandler,
814{
815    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
816
817    #[inline]
818    fn mutable_type() -> Option<(TypeId, &'static str)> {
819        let id = TypeId::of::<H::Data>();
820        let name = std::any::type_name::<H::Data>();
821        Some((id, name))
822    }
823
824    #[allow(unused_variables)]
825    unsafe fn handle_event(
826        &self,
827        queue: &Queue,
828        data: *mut u8,
829        slf: &UntypedBorrowedProxy,
830        opcode: u32,
831        args: *mut wl_argument,
832    ) {
833        // SAFETY: This function requires that slf has the interface INTERFACE
834        let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlPointerRef>(slf) };
835        // SAFETY: This function requires that data is `&mut T` where `T`
836        //         has the type id returned by `Self::mutable_type`, i.e.,
837        //         `T = H::Data`.
838        let data: &mut H::Data = unsafe { &mut *data.cast() };
839        match opcode {
840            0 => {
841                // SAFETY: INTERFACE requires that there are 4 arguments
842                let args = unsafe { &*args.cast::<[wl_argument; 4]>() };
843                // SAFETY: - INTERFACE requires that args[0] contains a uint
844                let arg0 = unsafe { args[0].u };
845                // SAFETY: - INTERFACE requires that args[1] contains an object
846                let arg1 = unsafe {
847                    if let Some(p) = NonNull::new(args[1].o.cast()) {
848                        Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
849                    } else {
850                        None
851                    }
852                };
853                // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
854                let arg1 = arg1.as_ref().map(|arg1| unsafe {
855                    proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg1)
856                });
857                // SAFETY: - INTERFACE requires that args[2] contains a fixed
858                let arg2 = unsafe { Fixed::from_wire(args[2].f) };
859                // SAFETY: - INTERFACE requires that args[3] contains a fixed
860                let arg3 = unsafe { Fixed::from_wire(args[3].f) };
861                self.0.enter(data, slf, arg0, arg1, arg2, arg3);
862            }
863            1 => {
864                // SAFETY: INTERFACE requires that there are 2 arguments
865                let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
866                // SAFETY: - INTERFACE requires that args[0] contains a uint
867                let arg0 = unsafe { args[0].u };
868                // SAFETY: - INTERFACE requires that args[1] contains an object
869                let arg1 = unsafe {
870                    if let Some(p) = NonNull::new(args[1].o.cast()) {
871                        Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
872                    } else {
873                        None
874                    }
875                };
876                // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
877                let arg1 = arg1.as_ref().map(|arg1| unsafe {
878                    proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg1)
879                });
880                self.0.leave(data, slf, arg0, arg1);
881            }
882            2 => {
883                // SAFETY: INTERFACE requires that there are 3 arguments
884                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
885                // SAFETY: - INTERFACE requires that args[0] contains a uint
886                let arg0 = unsafe { args[0].u };
887                // SAFETY: - INTERFACE requires that args[1] contains a fixed
888                let arg1 = unsafe { Fixed::from_wire(args[1].f) };
889                // SAFETY: - INTERFACE requires that args[2] contains a fixed
890                let arg2 = unsafe { Fixed::from_wire(args[2].f) };
891                self.0.motion(data, slf, arg0, arg1, arg2);
892            }
893            3 => {
894                // SAFETY: INTERFACE requires that there are 4 arguments
895                let args = unsafe { &*args.cast::<[wl_argument; 4]>() };
896                // SAFETY: - INTERFACE requires that args[0] contains a uint
897                let arg0 = unsafe { args[0].u };
898                // SAFETY: - INTERFACE requires that args[1] contains a uint
899                let arg1 = unsafe { args[1].u };
900                // SAFETY: - INTERFACE requires that args[2] contains a uint
901                let arg2 = unsafe { args[2].u };
902                // SAFETY: - INTERFACE requires that args[3] contains a uint
903                let arg3 = unsafe { WlPointerButtonState(args[3].u) };
904                self.0.button(data, slf, arg0, arg1, arg2, arg3);
905            }
906            4 => {
907                // SAFETY: INTERFACE requires that there are 3 arguments
908                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
909                // SAFETY: - INTERFACE requires that args[0] contains a uint
910                let arg0 = unsafe { args[0].u };
911                // SAFETY: - INTERFACE requires that args[1] contains a uint
912                let arg1 = unsafe { WlPointerAxis(args[1].u) };
913                // SAFETY: - INTERFACE requires that args[2] contains a fixed
914                let arg2 = unsafe { Fixed::from_wire(args[2].f) };
915                self.0.axis(data, slf, arg0, arg1, arg2);
916            }
917            5 => {
918                self.0.frame(data, slf);
919            }
920            6 => {
921                // SAFETY: INTERFACE requires that there are 1 arguments
922                let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
923                // SAFETY: - INTERFACE requires that args[0] contains a uint
924                let arg0 = unsafe { WlPointerAxisSource(args[0].u) };
925                self.0.axis_source(data, slf, arg0);
926            }
927            7 => {
928                // SAFETY: INTERFACE requires that there are 2 arguments
929                let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
930                // SAFETY: - INTERFACE requires that args[0] contains a uint
931                let arg0 = unsafe { args[0].u };
932                // SAFETY: - INTERFACE requires that args[1] contains a uint
933                let arg1 = unsafe { WlPointerAxis(args[1].u) };
934                self.0.axis_stop(data, slf, arg0, arg1);
935            }
936            8 => {
937                // SAFETY: INTERFACE requires that there are 2 arguments
938                let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
939                // SAFETY: - INTERFACE requires that args[0] contains a uint
940                let arg0 = unsafe { WlPointerAxis(args[0].u) };
941                // SAFETY: - INTERFACE requires that args[1] contains an int
942                let arg1 = unsafe { args[1].i };
943                self.0.axis_discrete(data, slf, arg0, arg1);
944            }
945            9 => {
946                // SAFETY: INTERFACE requires that there are 2 arguments
947                let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
948                // SAFETY: - INTERFACE requires that args[0] contains a uint
949                let arg0 = unsafe { WlPointerAxis(args[0].u) };
950                // SAFETY: - INTERFACE requires that args[1] contains an int
951                let arg1 = unsafe { args[1].i };
952                self.0.axis_value120(data, slf, arg0, arg1);
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 uint
958                let arg0 = unsafe { WlPointerAxis(args[0].u) };
959                // SAFETY: - INTERFACE requires that args[1] contains a uint
960                let arg1 = unsafe { WlPointerAxisRelativeDirection(args[1].u) };
961                self.0.axis_relative_direction(data, slf, arg0, arg1);
962            }
963            _ => {
964                invalid_opcode("wl_pointer", opcode);
965            }
966        }
967    }
968}
969
970impl<H> CreateEventHandler<H> for private::ProxyApi
971where
972    H: WlPointerEventHandler,
973{
974    type EventHandler = private::EventHandler<H>;
975
976    #[inline]
977    fn create_event_handler(handler: H) -> Self::EventHandler {
978        private::EventHandler(handler)
979    }
980}
981
982impl WlPointer {
983    /// Since when the error.role enum variant is available.
984    #[allow(dead_code)]
985    pub const ENM__ERROR_ROLE__SINCE: u32 = 1;
986
987    /// Since when the button_state.released enum variant is available.
988    #[allow(dead_code)]
989    pub const ENM__BUTTON_STATE_RELEASED__SINCE: u32 = 1;
990    /// Since when the button_state.pressed enum variant is available.
991    #[allow(dead_code)]
992    pub const ENM__BUTTON_STATE_PRESSED__SINCE: u32 = 1;
993
994    /// Since when the axis.vertical_scroll enum variant is available.
995    #[allow(dead_code)]
996    pub const ENM__AXIS_VERTICAL_SCROLL__SINCE: u32 = 1;
997    /// Since when the axis.horizontal_scroll enum variant is available.
998    #[allow(dead_code)]
999    pub const ENM__AXIS_HORIZONTAL_SCROLL__SINCE: u32 = 1;
1000
1001    /// Since when the axis_source.wheel enum variant is available.
1002    #[allow(dead_code)]
1003    pub const ENM__AXIS_SOURCE_WHEEL__SINCE: u32 = 1;
1004    /// Since when the axis_source.finger enum variant is available.
1005    #[allow(dead_code)]
1006    pub const ENM__AXIS_SOURCE_FINGER__SINCE: u32 = 1;
1007    /// Since when the axis_source.continuous enum variant is available.
1008    #[allow(dead_code)]
1009    pub const ENM__AXIS_SOURCE_CONTINUOUS__SINCE: u32 = 1;
1010    /// Since when the axis_source.wheel_tilt enum variant is available.
1011    #[allow(dead_code)]
1012    pub const ENM__AXIS_SOURCE_WHEEL_TILT__SINCE: u32 = 6;
1013
1014    /// Since when the axis_relative_direction.identical enum variant is available.
1015    #[allow(dead_code)]
1016    pub const ENM__AXIS_RELATIVE_DIRECTION_IDENTICAL__SINCE: u32 = 1;
1017    /// Since when the axis_relative_direction.inverted enum variant is available.
1018    #[allow(dead_code)]
1019    pub const ENM__AXIS_RELATIVE_DIRECTION_INVERTED__SINCE: u32 = 1;
1020}
1021
1022#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1023#[allow(dead_code)]
1024pub struct WlPointerError(pub u32);
1025
1026impl WlPointerError {
1027    /// given wl_surface has another role
1028    #[allow(dead_code)]
1029    pub const ROLE: Self = Self(0);
1030}
1031
1032impl Debug for WlPointerError {
1033    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1034        let name = match *self {
1035            Self::ROLE => "ROLE",
1036            _ => return Debug::fmt(&self.0, f),
1037        };
1038        f.write_str(name)
1039    }
1040}
1041
1042/// physical button state
1043///
1044/// Describes the physical state of a button that produced the button
1045/// event.
1046#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1047#[allow(dead_code)]
1048pub struct WlPointerButtonState(pub u32);
1049
1050impl WlPointerButtonState {
1051    /// the button is not pressed
1052    #[allow(dead_code)]
1053    pub const RELEASED: Self = Self(0);
1054
1055    /// the button is pressed
1056    #[allow(dead_code)]
1057    pub const PRESSED: Self = Self(1);
1058}
1059
1060impl Debug for WlPointerButtonState {
1061    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1062        let name = match *self {
1063            Self::RELEASED => "RELEASED",
1064            Self::PRESSED => "PRESSED",
1065            _ => return Debug::fmt(&self.0, f),
1066        };
1067        f.write_str(name)
1068    }
1069}
1070
1071/// axis types
1072///
1073/// Describes the axis types of scroll events.
1074#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1075#[allow(dead_code)]
1076pub struct WlPointerAxis(pub u32);
1077
1078impl WlPointerAxis {
1079    /// vertical axis
1080    #[allow(dead_code)]
1081    pub const VERTICAL_SCROLL: Self = Self(0);
1082
1083    /// horizontal axis
1084    #[allow(dead_code)]
1085    pub const HORIZONTAL_SCROLL: Self = Self(1);
1086}
1087
1088impl Debug for WlPointerAxis {
1089    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1090        let name = match *self {
1091            Self::VERTICAL_SCROLL => "VERTICAL_SCROLL",
1092            Self::HORIZONTAL_SCROLL => "HORIZONTAL_SCROLL",
1093            _ => return Debug::fmt(&self.0, f),
1094        };
1095        f.write_str(name)
1096    }
1097}
1098
1099/// axis source types
1100///
1101/// Describes the source types for axis events. This indicates to the
1102/// client how an axis event was physically generated; a client may
1103/// adjust the user interface accordingly. For example, scroll events
1104/// from a "finger" source may be in a smooth coordinate space with
1105/// kinetic scrolling whereas a "wheel" source may be in discrete steps
1106/// of a number of lines.
1107///
1108/// The "continuous" axis source is a device generating events in a
1109/// continuous coordinate space, but using something other than a
1110/// finger. One example for this source is button-based scrolling where
1111/// the vertical motion of a device is converted to scroll events while
1112/// a button is held down.
1113///
1114/// The "wheel tilt" axis source indicates that the actual device is a
1115/// wheel but the scroll event is not caused by a rotation but a
1116/// (usually sideways) tilt of the wheel.
1117#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1118#[allow(dead_code)]
1119pub struct WlPointerAxisSource(pub u32);
1120
1121impl WlPointerAxisSource {
1122    /// a physical wheel rotation
1123    #[allow(dead_code)]
1124    pub const WHEEL: Self = Self(0);
1125
1126    /// finger on a touch surface
1127    #[allow(dead_code)]
1128    pub const FINGER: Self = Self(1);
1129
1130    /// continuous coordinate space
1131    #[allow(dead_code)]
1132    pub const CONTINUOUS: Self = Self(2);
1133
1134    /// a physical wheel tilt
1135    #[allow(dead_code)]
1136    pub const WHEEL_TILT: Self = Self(3);
1137}
1138
1139impl Debug for WlPointerAxisSource {
1140    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1141        let name = match *self {
1142            Self::WHEEL => "WHEEL",
1143            Self::FINGER => "FINGER",
1144            Self::CONTINUOUS => "CONTINUOUS",
1145            Self::WHEEL_TILT => "WHEEL_TILT",
1146            _ => return Debug::fmt(&self.0, f),
1147        };
1148        f.write_str(name)
1149    }
1150}
1151
1152/// axis relative direction
1153///
1154/// This specifies the direction of the physical motion that caused a
1155/// wl_pointer.axis event, relative to the wl_pointer.axis direction.
1156#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1157#[allow(dead_code)]
1158pub struct WlPointerAxisRelativeDirection(pub u32);
1159
1160impl WlPointerAxisRelativeDirection {
1161    /// physical motion matches axis direction
1162    #[allow(dead_code)]
1163    pub const IDENTICAL: Self = Self(0);
1164
1165    /// physical motion is the inverse of the axis direction
1166    #[allow(dead_code)]
1167    pub const INVERTED: Self = Self(1);
1168}
1169
1170impl Debug for WlPointerAxisRelativeDirection {
1171    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1172        let name = match *self {
1173            Self::IDENTICAL => "IDENTICAL",
1174            Self::INVERTED => "INVERTED",
1175            _ => return Debug::fmt(&self.0, f),
1176        };
1177        f.write_str(name)
1178    }
1179}
1180
1181/// Functional event handlers.
1182pub mod event_handlers {
1183    use super::*;
1184
1185    /// Event handler for enter events.
1186    pub struct Enter<T, F>(F, PhantomData<fn(&mut T)>);
1187    impl<T, F> WlPointerEventHandler for Enter<T, F>
1188    where
1189        T: 'static,
1190        F: Fn(&mut T, &WlPointerRef, u32, Option<&WlSurfaceRef>, Fixed, Fixed),
1191    {
1192        type Data = T;
1193
1194        #[inline]
1195        fn enter(
1196            &self,
1197            _data: &mut T,
1198            _slf: &WlPointerRef,
1199            serial: u32,
1200            surface: Option<&WlSurfaceRef>,
1201            surface_x: Fixed,
1202            surface_y: Fixed,
1203        ) {
1204            self.0(_data, _slf, serial, surface, surface_x, surface_y)
1205        }
1206    }
1207
1208    /// Event handler for leave events.
1209    pub struct Leave<T, F>(F, PhantomData<fn(&mut T)>);
1210    impl<T, F> WlPointerEventHandler for Leave<T, F>
1211    where
1212        T: 'static,
1213        F: Fn(&mut T, &WlPointerRef, u32, Option<&WlSurfaceRef>),
1214    {
1215        type Data = T;
1216
1217        #[inline]
1218        fn leave(
1219            &self,
1220            _data: &mut T,
1221            _slf: &WlPointerRef,
1222            serial: u32,
1223            surface: Option<&WlSurfaceRef>,
1224        ) {
1225            self.0(_data, _slf, serial, surface)
1226        }
1227    }
1228
1229    /// Event handler for motion events.
1230    pub struct Motion<T, F>(F, PhantomData<fn(&mut T)>);
1231    impl<T, F> WlPointerEventHandler for Motion<T, F>
1232    where
1233        T: 'static,
1234        F: Fn(&mut T, &WlPointerRef, u32, Fixed, Fixed),
1235    {
1236        type Data = T;
1237
1238        #[inline]
1239        fn motion(
1240            &self,
1241            _data: &mut T,
1242            _slf: &WlPointerRef,
1243            time: u32,
1244            surface_x: Fixed,
1245            surface_y: Fixed,
1246        ) {
1247            self.0(_data, _slf, time, surface_x, surface_y)
1248        }
1249    }
1250
1251    /// Event handler for button events.
1252    pub struct Button<T, F>(F, PhantomData<fn(&mut T)>);
1253    impl<T, F> WlPointerEventHandler for Button<T, F>
1254    where
1255        T: 'static,
1256        F: Fn(&mut T, &WlPointerRef, u32, u32, u32, WlPointerButtonState),
1257    {
1258        type Data = T;
1259
1260        #[inline]
1261        fn button(
1262            &self,
1263            _data: &mut T,
1264            _slf: &WlPointerRef,
1265            serial: u32,
1266            time: u32,
1267            button: u32,
1268            state: WlPointerButtonState,
1269        ) {
1270            self.0(_data, _slf, serial, time, button, state)
1271        }
1272    }
1273
1274    /// Event handler for axis events.
1275    pub struct Axis<T, F>(F, PhantomData<fn(&mut T)>);
1276    impl<T, F> WlPointerEventHandler for Axis<T, F>
1277    where
1278        T: 'static,
1279        F: Fn(&mut T, &WlPointerRef, u32, WlPointerAxis, Fixed),
1280    {
1281        type Data = T;
1282
1283        #[inline]
1284        fn axis(
1285            &self,
1286            _data: &mut T,
1287            _slf: &WlPointerRef,
1288            time: u32,
1289            axis: WlPointerAxis,
1290            value: Fixed,
1291        ) {
1292            self.0(_data, _slf, time, axis, value)
1293        }
1294    }
1295
1296    /// Event handler for frame events.
1297    pub struct Frame<T, F>(F, PhantomData<fn(&mut T)>);
1298    impl<T, F> WlPointerEventHandler for Frame<T, F>
1299    where
1300        T: 'static,
1301        F: Fn(&mut T, &WlPointerRef),
1302    {
1303        type Data = T;
1304
1305        #[inline]
1306        fn frame(&self, _data: &mut T, _slf: &WlPointerRef) {
1307            self.0(_data, _slf)
1308        }
1309    }
1310
1311    /// Event handler for axis_source events.
1312    pub struct AxisSource<T, F>(F, PhantomData<fn(&mut T)>);
1313    impl<T, F> WlPointerEventHandler for AxisSource<T, F>
1314    where
1315        T: 'static,
1316        F: Fn(&mut T, &WlPointerRef, WlPointerAxisSource),
1317    {
1318        type Data = T;
1319
1320        #[inline]
1321        fn axis_source(
1322            &self,
1323            _data: &mut T,
1324            _slf: &WlPointerRef,
1325            axis_source: WlPointerAxisSource,
1326        ) {
1327            self.0(_data, _slf, axis_source)
1328        }
1329    }
1330
1331    /// Event handler for axis_stop events.
1332    pub struct AxisStop<T, F>(F, PhantomData<fn(&mut T)>);
1333    impl<T, F> WlPointerEventHandler for AxisStop<T, F>
1334    where
1335        T: 'static,
1336        F: Fn(&mut T, &WlPointerRef, u32, WlPointerAxis),
1337    {
1338        type Data = T;
1339
1340        #[inline]
1341        fn axis_stop(&self, _data: &mut T, _slf: &WlPointerRef, time: u32, axis: WlPointerAxis) {
1342            self.0(_data, _slf, time, axis)
1343        }
1344    }
1345
1346    /// Event handler for axis_discrete events.
1347    pub struct AxisDiscrete<T, F>(F, PhantomData<fn(&mut T)>);
1348    impl<T, F> WlPointerEventHandler for AxisDiscrete<T, F>
1349    where
1350        T: 'static,
1351        F: Fn(&mut T, &WlPointerRef, WlPointerAxis, i32),
1352    {
1353        type Data = T;
1354
1355        #[inline]
1356        fn axis_discrete(
1357            &self,
1358            _data: &mut T,
1359            _slf: &WlPointerRef,
1360            axis: WlPointerAxis,
1361            discrete: i32,
1362        ) {
1363            self.0(_data, _slf, axis, discrete)
1364        }
1365    }
1366
1367    /// Event handler for axis_value120 events.
1368    pub struct AxisValue120<T, F>(F, PhantomData<fn(&mut T)>);
1369    impl<T, F> WlPointerEventHandler for AxisValue120<T, F>
1370    where
1371        T: 'static,
1372        F: Fn(&mut T, &WlPointerRef, WlPointerAxis, i32),
1373    {
1374        type Data = T;
1375
1376        #[inline]
1377        fn axis_value120(
1378            &self,
1379            _data: &mut T,
1380            _slf: &WlPointerRef,
1381            axis: WlPointerAxis,
1382            value120: i32,
1383        ) {
1384            self.0(_data, _slf, axis, value120)
1385        }
1386    }
1387
1388    /// Event handler for axis_relative_direction events.
1389    pub struct AxisRelativeDirection<T, F>(F, PhantomData<fn(&mut T)>);
1390    impl<T, F> WlPointerEventHandler for AxisRelativeDirection<T, F>
1391    where
1392        T: 'static,
1393        F: Fn(&mut T, &WlPointerRef, WlPointerAxis, WlPointerAxisRelativeDirection),
1394    {
1395        type Data = T;
1396
1397        #[inline]
1398        fn axis_relative_direction(
1399            &self,
1400            _data: &mut T,
1401            _slf: &WlPointerRef,
1402            axis: WlPointerAxis,
1403            direction: WlPointerAxisRelativeDirection,
1404        ) {
1405            self.0(_data, _slf, axis, direction)
1406        }
1407    }
1408
1409    impl WlPointer {
1410        /// Creates an event handler for enter events.
1411        ///
1412        /// The event handler ignores all other events.
1413        #[allow(dead_code)]
1414        pub fn on_enter<T, F>(f: F) -> Enter<T, F>
1415        where
1416            T: 'static,
1417            F: Fn(&mut T, &WlPointerRef, u32, Option<&WlSurfaceRef>, Fixed, Fixed),
1418        {
1419            Enter(f, PhantomData)
1420        }
1421
1422        /// Creates an event handler for leave events.
1423        ///
1424        /// The event handler ignores all other events.
1425        #[allow(dead_code)]
1426        pub fn on_leave<T, F>(f: F) -> Leave<T, F>
1427        where
1428            T: 'static,
1429            F: Fn(&mut T, &WlPointerRef, u32, Option<&WlSurfaceRef>),
1430        {
1431            Leave(f, PhantomData)
1432        }
1433
1434        /// Creates an event handler for motion events.
1435        ///
1436        /// The event handler ignores all other events.
1437        #[allow(dead_code)]
1438        pub fn on_motion<T, F>(f: F) -> Motion<T, F>
1439        where
1440            T: 'static,
1441            F: Fn(&mut T, &WlPointerRef, u32, Fixed, Fixed),
1442        {
1443            Motion(f, PhantomData)
1444        }
1445
1446        /// Creates an event handler for button events.
1447        ///
1448        /// The event handler ignores all other events.
1449        #[allow(dead_code)]
1450        pub fn on_button<T, F>(f: F) -> Button<T, F>
1451        where
1452            T: 'static,
1453            F: Fn(&mut T, &WlPointerRef, u32, u32, u32, WlPointerButtonState),
1454        {
1455            Button(f, PhantomData)
1456        }
1457
1458        /// Creates an event handler for axis events.
1459        ///
1460        /// The event handler ignores all other events.
1461        #[allow(dead_code)]
1462        pub fn on_axis<T, F>(f: F) -> Axis<T, F>
1463        where
1464            T: 'static,
1465            F: Fn(&mut T, &WlPointerRef, u32, WlPointerAxis, Fixed),
1466        {
1467            Axis(f, PhantomData)
1468        }
1469
1470        /// Creates an event handler for frame events.
1471        ///
1472        /// The event handler ignores all other events.
1473        #[allow(dead_code)]
1474        pub fn on_frame<T, F>(f: F) -> Frame<T, F>
1475        where
1476            T: 'static,
1477            F: Fn(&mut T, &WlPointerRef),
1478        {
1479            Frame(f, PhantomData)
1480        }
1481
1482        /// Creates an event handler for axis_source events.
1483        ///
1484        /// The event handler ignores all other events.
1485        #[allow(dead_code)]
1486        pub fn on_axis_source<T, F>(f: F) -> AxisSource<T, F>
1487        where
1488            T: 'static,
1489            F: Fn(&mut T, &WlPointerRef, WlPointerAxisSource),
1490        {
1491            AxisSource(f, PhantomData)
1492        }
1493
1494        /// Creates an event handler for axis_stop events.
1495        ///
1496        /// The event handler ignores all other events.
1497        #[allow(dead_code)]
1498        pub fn on_axis_stop<T, F>(f: F) -> AxisStop<T, F>
1499        where
1500            T: 'static,
1501            F: Fn(&mut T, &WlPointerRef, u32, WlPointerAxis),
1502        {
1503            AxisStop(f, PhantomData)
1504        }
1505
1506        /// Creates an event handler for axis_discrete events.
1507        ///
1508        /// The event handler ignores all other events.
1509        #[allow(dead_code)]
1510        pub fn on_axis_discrete<T, F>(f: F) -> AxisDiscrete<T, F>
1511        where
1512            T: 'static,
1513            F: Fn(&mut T, &WlPointerRef, WlPointerAxis, i32),
1514        {
1515            AxisDiscrete(f, PhantomData)
1516        }
1517
1518        /// Creates an event handler for axis_value120 events.
1519        ///
1520        /// The event handler ignores all other events.
1521        #[allow(dead_code)]
1522        pub fn on_axis_value120<T, F>(f: F) -> AxisValue120<T, F>
1523        where
1524            T: 'static,
1525            F: Fn(&mut T, &WlPointerRef, WlPointerAxis, i32),
1526        {
1527            AxisValue120(f, PhantomData)
1528        }
1529
1530        /// Creates an event handler for axis_relative_direction events.
1531        ///
1532        /// The event handler ignores all other events.
1533        #[allow(dead_code)]
1534        pub fn on_axis_relative_direction<T, F>(f: F) -> AxisRelativeDirection<T, F>
1535        where
1536            T: 'static,
1537            F: Fn(&mut T, &WlPointerRef, WlPointerAxis, WlPointerAxisRelativeDirection),
1538        {
1539            AxisRelativeDirection(f, PhantomData)
1540        }
1541    }
1542}