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