async_roundtrip/common/protocols_data/wayland/
wl_touch.rs

1//! touchscreen input device
2//!
3//! The wl_touch interface represents a touchscreen
4//! associated with a seat.
5//!
6//! Touch interactions can consist of one or more contacts.
7//! For each contact, a series of events is generated, starting
8//! with a down event, followed by zero or more motion events,
9//! and ending with an up event. Events relating to the same
10//! contact point can be identified by the ID of the sequence.
11
12use {super::super::all_types::*, ::wl_client::builder::prelude::*};
13
14static INTERFACE: wl_interface = wl_interface {
15    name: c"wl_touch".as_ptr(),
16    version: 10,
17    method_count: 1,
18    methods: {
19        static MESSAGES: [wl_message; 1] = [wl_message {
20            name: c"release".as_ptr(),
21            signature: c"".as_ptr(),
22            types: {
23                static TYPES: [Option<&'static wl_interface>; 0] = [];
24                TYPES.as_ptr().cast()
25            },
26        }];
27        MESSAGES.as_ptr()
28    },
29    event_count: 7,
30    events: {
31        static MESSAGES: [wl_message; 7] = [
32            wl_message {
33                name: c"down".as_ptr(),
34                signature: c"uuoiff".as_ptr(),
35                types: {
36                    static TYPES: [Option<&'static wl_interface>; 6] =
37                        [None, None, Some(WlSurface::WL_INTERFACE), None, None, None];
38                    TYPES.as_ptr().cast()
39                },
40            },
41            wl_message {
42                name: c"up".as_ptr(),
43                signature: c"uui".as_ptr(),
44                types: {
45                    static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
46                    TYPES.as_ptr().cast()
47                },
48            },
49            wl_message {
50                name: c"motion".as_ptr(),
51                signature: c"uiff".as_ptr(),
52                types: {
53                    static TYPES: [Option<&'static wl_interface>; 4] = [None, None, None, None];
54                    TYPES.as_ptr().cast()
55                },
56            },
57            wl_message {
58                name: c"frame".as_ptr(),
59                signature: c"".as_ptr(),
60                types: {
61                    static TYPES: [Option<&'static wl_interface>; 0] = [];
62                    TYPES.as_ptr().cast()
63                },
64            },
65            wl_message {
66                name: c"cancel".as_ptr(),
67                signature: c"".as_ptr(),
68                types: {
69                    static TYPES: [Option<&'static wl_interface>; 0] = [];
70                    TYPES.as_ptr().cast()
71                },
72            },
73            wl_message {
74                name: c"shape".as_ptr(),
75                signature: c"iff".as_ptr(),
76                types: {
77                    static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
78                    TYPES.as_ptr().cast()
79                },
80            },
81            wl_message {
82                name: c"orientation".as_ptr(),
83                signature: c"if".as_ptr(),
84                types: {
85                    static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
86                    TYPES.as_ptr().cast()
87                },
88            },
89        ];
90        MESSAGES.as_ptr()
91    },
92};
93
94/// An owned wl_touch proxy.
95///
96/// See the documentation of [the module][self] for the interface description.
97#[derive(Clone, Eq, PartialEq)]
98#[repr(transparent)]
99pub struct WlTouch {
100    /// This proxy has the interface INTERFACE.
101    proxy: UntypedOwnedProxy,
102}
103
104/// A borrowed wl_touch proxy.
105///
106/// See the documentation of [the module][self] for the interface description.
107#[derive(Eq, PartialEq)]
108#[repr(transparent)]
109pub struct WlTouchRef {
110    /// This proxy has the interface INTERFACE.
111    proxy: UntypedBorrowedProxy,
112}
113
114// SAFETY: WlTouch is a transparent wrapper around UntypedOwnedProxy
115unsafe impl UntypedOwnedProxyWrapper for WlTouch {}
116
117// SAFETY: - INTERFACE is a valid wl_interface
118//         - The only invariant is that self.proxy has a compatible interface
119unsafe impl OwnedProxy for WlTouch {
120    const INTERFACE: &'static str = "wl_touch";
121    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
122    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
123        private::EventHandler(private::NoOpEventHandler);
124    const MAX_VERSION: u32 = 10;
125
126    type Borrowed = WlTouchRef;
127    type Api = private::ProxyApi;
128    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
129}
130
131// SAFETY: WlTouchRef is a transparent wrapper around UntypedBorrowedProxy
132unsafe impl UntypedBorrowedProxyWrapper for WlTouchRef {}
133
134// SAFETY: - The only invariant is that self.proxy has a compatible interface
135unsafe impl BorrowedProxy for WlTouchRef {
136    type Owned = WlTouch;
137}
138
139impl Deref for WlTouch {
140    type Target = WlTouchRef;
141
142    fn deref(&self) -> &Self::Target {
143        proxy::low_level::deref(self)
144    }
145}
146
147mod private {
148    pub struct ProxyApi;
149
150    #[allow(dead_code)]
151    pub struct EventHandler<H>(pub(super) H);
152
153    #[allow(dead_code)]
154    pub struct NoOpEventHandler;
155}
156
157impl Debug for WlTouch {
158    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
159        write!(f, "wl_touch#{}", self.proxy.id())
160    }
161}
162
163impl Debug for WlTouchRef {
164    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
165        write!(f, "wl_touch#{}", self.proxy.id())
166    }
167}
168
169impl PartialEq<WlTouchRef> for WlTouch {
170    fn eq(&self, other: &WlTouchRef) -> bool {
171        self.proxy == other.proxy
172    }
173}
174
175impl PartialEq<WlTouch> for WlTouchRef {
176    fn eq(&self, other: &WlTouch) -> bool {
177        self.proxy == other.proxy
178    }
179}
180
181#[allow(dead_code)]
182impl WlTouch {
183    /// Since when the release request is available.
184    #[allow(dead_code)]
185    pub const REQ__RELEASE__SINCE: u32 = 3;
186
187    /// release the touch object
188    #[inline]
189    pub fn release(&self) {
190        let mut args = [];
191        // SAFETY: - self.proxy has the interface INTERFACE
192        //         - 0 < INTERFACE.method_count = 1
193        //         - the request signature is ``
194        unsafe {
195            self.proxy.send_destructor(0, &mut args);
196        }
197    }
198}
199
200impl WlTouch {
201    /// Since when the down event is available.
202    #[allow(dead_code)]
203    pub const EVT__DOWN__SINCE: u32 = 1;
204
205    /// Since when the up event is available.
206    #[allow(dead_code)]
207    pub const EVT__UP__SINCE: u32 = 1;
208
209    /// Since when the motion event is available.
210    #[allow(dead_code)]
211    pub const EVT__MOTION__SINCE: u32 = 1;
212
213    /// Since when the frame event is available.
214    #[allow(dead_code)]
215    pub const EVT__FRAME__SINCE: u32 = 1;
216
217    /// Since when the cancel event is available.
218    #[allow(dead_code)]
219    pub const EVT__CANCEL__SINCE: u32 = 1;
220
221    /// Since when the shape event is available.
222    #[allow(dead_code)]
223    pub const EVT__SHAPE__SINCE: u32 = 6;
224
225    /// Since when the orientation event is available.
226    #[allow(dead_code)]
227    pub const EVT__ORIENTATION__SINCE: u32 = 6;
228}
229
230/// An event handler for [WlTouch] proxies.
231#[allow(dead_code)]
232pub trait WlTouchEventHandler {
233    type Data: 'static;
234
235    /// touch down event and beginning of a touch sequence
236    ///
237    /// A new touch point has appeared on the surface. This touch point is
238    /// assigned a unique ID. Future events from this touch point reference
239    /// this ID. The ID ceases to be valid after a touch up event and may be
240    /// reused in the future.
241    ///
242    /// # Arguments
243    ///
244    /// - `serial`: serial number of the touch down event
245    /// - `time`: timestamp with millisecond granularity
246    /// - `surface`: surface touched
247    /// - `id`: the unique ID of this touch point
248    /// - `x`: surface-local x coordinate
249    /// - `y`: surface-local y coordinate
250    ///
251    /// All borrowed proxies passed to this function are guaranteed to be
252    /// immutable and non-null.
253    #[inline]
254    fn down(
255        &self,
256        _data: &mut Self::Data,
257        _slf: &WlTouchRef,
258        serial: u32,
259        time: u32,
260        surface: Option<&WlSurfaceRef>,
261        id: i32,
262        x: Fixed,
263        y: Fixed,
264    ) {
265        let _ = serial;
266        let _ = time;
267        let _ = surface;
268        let _ = id;
269        let _ = x;
270        let _ = y;
271    }
272
273    /// end of a touch event sequence
274    ///
275    /// The touch point has disappeared. No further events will be sent for
276    /// this touch point and the touch point's ID is released and may be
277    /// reused in a future touch down event.
278    ///
279    /// # Arguments
280    ///
281    /// - `serial`: serial number of the touch up event
282    /// - `time`: timestamp with millisecond granularity
283    /// - `id`: the unique ID of this touch point
284    #[inline]
285    fn up(&self, _data: &mut Self::Data, _slf: &WlTouchRef, serial: u32, time: u32, id: i32) {
286        let _ = serial;
287        let _ = time;
288        let _ = id;
289    }
290
291    /// update of touch point coordinates
292    ///
293    /// A touch point has changed coordinates.
294    ///
295    /// # Arguments
296    ///
297    /// - `time`: timestamp with millisecond granularity
298    /// - `id`: the unique ID of this touch point
299    /// - `x`: surface-local x coordinate
300    /// - `y`: surface-local y coordinate
301    #[inline]
302    fn motion(
303        &self,
304        _data: &mut Self::Data,
305        _slf: &WlTouchRef,
306        time: u32,
307        id: i32,
308        x: Fixed,
309        y: Fixed,
310    ) {
311        let _ = time;
312        let _ = id;
313        let _ = x;
314        let _ = y;
315    }
316
317    /// end of touch frame event
318    ///
319    /// Indicates the end of a set of events that logically belong together.
320    /// A client is expected to accumulate the data in all events within the
321    /// frame before proceeding.
322    ///
323    /// A wl_touch.frame terminates at least one event but otherwise no
324    /// guarantee is provided about the set of events within a frame. A client
325    /// must assume that any state not updated in a frame is unchanged from the
326    /// previously known state.
327    #[inline]
328    fn frame(&self, _data: &mut Self::Data, _slf: &WlTouchRef) {}
329
330    /// touch session cancelled
331    ///
332    /// Sent if the compositor decides the touch stream is a global
333    /// gesture. No further events are sent to the clients from that
334    /// particular gesture. Touch cancellation applies to all touch points
335    /// currently active on this client's surface. The client is
336    /// responsible for finalizing the touch points, future touch points on
337    /// this surface may reuse the touch point ID.
338    ///
339    /// No frame event is required after the cancel event.
340    #[inline]
341    fn cancel(&self, _data: &mut Self::Data, _slf: &WlTouchRef) {}
342
343    /// update shape of touch point
344    ///
345    /// Sent when a touchpoint has changed its shape.
346    ///
347    /// This event does not occur on its own. It is sent before a
348    /// wl_touch.frame event and carries the new shape information for
349    /// any previously reported, or new touch points of that frame.
350    ///
351    /// Other events describing the touch point such as wl_touch.down,
352    /// wl_touch.motion or wl_touch.orientation may be sent within the
353    /// same wl_touch.frame. A client should treat these events as a single
354    /// logical touch point update. The order of wl_touch.shape,
355    /// wl_touch.orientation and wl_touch.motion is not guaranteed.
356    /// A wl_touch.down event is guaranteed to occur before the first
357    /// wl_touch.shape event for this touch ID but both events may occur within
358    /// the same wl_touch.frame.
359    ///
360    /// A touchpoint shape is approximated by an ellipse through the major and
361    /// minor axis length. The major axis length describes the longer diameter
362    /// of the ellipse, while the minor axis length describes the shorter
363    /// diameter. Major and minor are orthogonal and both are specified in
364    /// surface-local coordinates. The center of the ellipse is always at the
365    /// touchpoint location as reported by wl_touch.down or wl_touch.move.
366    ///
367    /// This event is only sent by the compositor if the touch device supports
368    /// shape reports. The client has to make reasonable assumptions about the
369    /// shape if it did not receive this event.
370    ///
371    /// # Arguments
372    ///
373    /// - `id`: the unique ID of this touch point
374    /// - `major`: length of the major axis in surface-local coordinates
375    /// - `minor`: length of the minor axis in surface-local coordinates
376    #[inline]
377    fn shape(
378        &self,
379        _data: &mut Self::Data,
380        _slf: &WlTouchRef,
381        id: i32,
382        major: Fixed,
383        minor: Fixed,
384    ) {
385        let _ = id;
386        let _ = major;
387        let _ = minor;
388    }
389
390    /// update orientation of touch point
391    ///
392    /// Sent when a touchpoint has changed its orientation.
393    ///
394    /// This event does not occur on its own. It is sent before a
395    /// wl_touch.frame event and carries the new shape information for
396    /// any previously reported, or new touch points of that frame.
397    ///
398    /// Other events describing the touch point such as wl_touch.down,
399    /// wl_touch.motion or wl_touch.shape may be sent within the
400    /// same wl_touch.frame. A client should treat these events as a single
401    /// logical touch point update. The order of wl_touch.shape,
402    /// wl_touch.orientation and wl_touch.motion is not guaranteed.
403    /// A wl_touch.down event is guaranteed to occur before the first
404    /// wl_touch.orientation event for this touch ID but both events may occur
405    /// within the same wl_touch.frame.
406    ///
407    /// The orientation describes the clockwise angle of a touchpoint's major
408    /// axis to the positive surface y-axis and is normalized to the -180 to
409    /// +180 degree range. The granularity of orientation depends on the touch
410    /// device, some devices only support binary rotation values between 0 and
411    /// 90 degrees.
412    ///
413    /// This event is only sent by the compositor if the touch device supports
414    /// orientation reports.
415    ///
416    /// # Arguments
417    ///
418    /// - `id`: the unique ID of this touch point
419    /// - `orientation`: angle between major axis and positive surface y-axis in degrees
420    #[inline]
421    fn orientation(&self, _data: &mut Self::Data, _slf: &WlTouchRef, id: i32, orientation: Fixed) {
422        let _ = id;
423        let _ = orientation;
424    }
425}
426
427impl WlTouchEventHandler for private::NoOpEventHandler {
428    type Data = ();
429}
430
431// SAFETY: - INTERFACE is a valid wl_interface
432//         - mutable_type always returns the same value
433unsafe impl<H> EventHandler for private::EventHandler<H>
434where
435    H: WlTouchEventHandler,
436{
437    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
438
439    #[inline]
440    fn mutable_type() -> Option<(TypeId, &'static str)> {
441        let id = TypeId::of::<H::Data>();
442        let name = std::any::type_name::<H::Data>();
443        Some((id, name))
444    }
445
446    #[allow(unused_variables)]
447    unsafe fn handle_event(
448        &self,
449        queue: &Queue,
450        data: *mut u8,
451        slf: &UntypedBorrowedProxy,
452        opcode: u32,
453        args: *mut wl_argument,
454    ) {
455        // SAFETY: This function requires that slf has the interface INTERFACE
456        let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlTouchRef>(slf) };
457        // SAFETY: This function requires that data is `&mut T` where `T`
458        //         has the type id returned by `Self::mutable_type`, i.e.,
459        //         `T = H::Data`.
460        let data: &mut H::Data = unsafe { &mut *data.cast() };
461        match opcode {
462            0 => {
463                // SAFETY: INTERFACE requires that there are 6 arguments
464                let args = unsafe { &*args.cast::<[wl_argument; 6]>() };
465                // SAFETY: - INTERFACE requires that args[0] contains a uint
466                let arg0 = unsafe { args[0].u };
467                // SAFETY: - INTERFACE requires that args[1] contains a uint
468                let arg1 = unsafe { args[1].u };
469                // SAFETY: - INTERFACE requires that args[2] contains an object
470                let arg2 = unsafe {
471                    if let Some(p) = NonNull::new(args[2].o.cast()) {
472                        Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
473                    } else {
474                        None
475                    }
476                };
477                // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
478                let arg2 = arg2.as_ref().map(|arg2| unsafe {
479                    proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg2)
480                });
481                // SAFETY: - INTERFACE requires that args[3] contains an int
482                let arg3 = unsafe { args[3].i };
483                // SAFETY: - INTERFACE requires that args[4] contains a fixed
484                let arg4 = unsafe { Fixed::from_wire(args[4].f) };
485                // SAFETY: - INTERFACE requires that args[5] contains a fixed
486                let arg5 = unsafe { Fixed::from_wire(args[5].f) };
487                self.0.down(data, slf, arg0, arg1, arg2, arg3, arg4, arg5);
488            }
489            1 => {
490                // SAFETY: INTERFACE requires that there are 3 arguments
491                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
492                // SAFETY: - INTERFACE requires that args[0] contains a uint
493                let arg0 = unsafe { args[0].u };
494                // SAFETY: - INTERFACE requires that args[1] contains a uint
495                let arg1 = unsafe { args[1].u };
496                // SAFETY: - INTERFACE requires that args[2] contains an int
497                let arg2 = unsafe { args[2].i };
498                self.0.up(data, slf, arg0, arg1, arg2);
499            }
500            2 => {
501                // SAFETY: INTERFACE requires that there are 4 arguments
502                let args = unsafe { &*args.cast::<[wl_argument; 4]>() };
503                // SAFETY: - INTERFACE requires that args[0] contains a uint
504                let arg0 = unsafe { args[0].u };
505                // SAFETY: - INTERFACE requires that args[1] contains an int
506                let arg1 = unsafe { args[1].i };
507                // SAFETY: - INTERFACE requires that args[2] contains a fixed
508                let arg2 = unsafe { Fixed::from_wire(args[2].f) };
509                // SAFETY: - INTERFACE requires that args[3] contains a fixed
510                let arg3 = unsafe { Fixed::from_wire(args[3].f) };
511                self.0.motion(data, slf, arg0, arg1, arg2, arg3);
512            }
513            3 => {
514                self.0.frame(data, slf);
515            }
516            4 => {
517                self.0.cancel(data, slf);
518            }
519            5 => {
520                // SAFETY: INTERFACE requires that there are 3 arguments
521                let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
522                // SAFETY: - INTERFACE requires that args[0] contains an int
523                let arg0 = unsafe { args[0].i };
524                // SAFETY: - INTERFACE requires that args[1] contains a fixed
525                let arg1 = unsafe { Fixed::from_wire(args[1].f) };
526                // SAFETY: - INTERFACE requires that args[2] contains a fixed
527                let arg2 = unsafe { Fixed::from_wire(args[2].f) };
528                self.0.shape(data, slf, arg0, arg1, arg2);
529            }
530            6 => {
531                // SAFETY: INTERFACE requires that there are 2 arguments
532                let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
533                // SAFETY: - INTERFACE requires that args[0] contains an int
534                let arg0 = unsafe { args[0].i };
535                // SAFETY: - INTERFACE requires that args[1] contains a fixed
536                let arg1 = unsafe { Fixed::from_wire(args[1].f) };
537                self.0.orientation(data, slf, arg0, arg1);
538            }
539            _ => {
540                invalid_opcode("wl_touch", opcode);
541            }
542        }
543    }
544}
545
546impl<H> CreateEventHandler<H> for private::ProxyApi
547where
548    H: WlTouchEventHandler,
549{
550    type EventHandler = private::EventHandler<H>;
551
552    #[inline]
553    fn create_event_handler(handler: H) -> Self::EventHandler {
554        private::EventHandler(handler)
555    }
556}
557
558/// Functional event handlers.
559pub mod event_handlers {
560    use super::*;
561
562    /// Event handler for down events.
563    pub struct Down<T, F>(F, PhantomData<fn(&mut T)>);
564    impl<T, F> WlTouchEventHandler for Down<T, F>
565    where
566        T: 'static,
567        F: Fn(&mut T, &WlTouchRef, u32, u32, Option<&WlSurfaceRef>, i32, Fixed, Fixed),
568    {
569        type Data = T;
570
571        #[inline]
572        fn down(
573            &self,
574            _data: &mut T,
575            _slf: &WlTouchRef,
576            serial: u32,
577            time: u32,
578            surface: Option<&WlSurfaceRef>,
579            id: i32,
580            x: Fixed,
581            y: Fixed,
582        ) {
583            self.0(_data, _slf, serial, time, surface, id, x, y)
584        }
585    }
586
587    /// Event handler for up events.
588    pub struct Up<T, F>(F, PhantomData<fn(&mut T)>);
589    impl<T, F> WlTouchEventHandler for Up<T, F>
590    where
591        T: 'static,
592        F: Fn(&mut T, &WlTouchRef, u32, u32, i32),
593    {
594        type Data = T;
595
596        #[inline]
597        fn up(&self, _data: &mut T, _slf: &WlTouchRef, serial: u32, time: u32, id: i32) {
598            self.0(_data, _slf, serial, time, id)
599        }
600    }
601
602    /// Event handler for motion events.
603    pub struct Motion<T, F>(F, PhantomData<fn(&mut T)>);
604    impl<T, F> WlTouchEventHandler for Motion<T, F>
605    where
606        T: 'static,
607        F: Fn(&mut T, &WlTouchRef, u32, i32, Fixed, Fixed),
608    {
609        type Data = T;
610
611        #[inline]
612        fn motion(&self, _data: &mut T, _slf: &WlTouchRef, time: u32, id: i32, x: Fixed, y: Fixed) {
613            self.0(_data, _slf, time, id, x, y)
614        }
615    }
616
617    /// Event handler for frame events.
618    pub struct Frame<T, F>(F, PhantomData<fn(&mut T)>);
619    impl<T, F> WlTouchEventHandler for Frame<T, F>
620    where
621        T: 'static,
622        F: Fn(&mut T, &WlTouchRef),
623    {
624        type Data = T;
625
626        #[inline]
627        fn frame(&self, _data: &mut T, _slf: &WlTouchRef) {
628            self.0(_data, _slf)
629        }
630    }
631
632    /// Event handler for cancel events.
633    pub struct Cancel<T, F>(F, PhantomData<fn(&mut T)>);
634    impl<T, F> WlTouchEventHandler for Cancel<T, F>
635    where
636        T: 'static,
637        F: Fn(&mut T, &WlTouchRef),
638    {
639        type Data = T;
640
641        #[inline]
642        fn cancel(&self, _data: &mut T, _slf: &WlTouchRef) {
643            self.0(_data, _slf)
644        }
645    }
646
647    /// Event handler for shape events.
648    pub struct Shape<T, F>(F, PhantomData<fn(&mut T)>);
649    impl<T, F> WlTouchEventHandler for Shape<T, F>
650    where
651        T: 'static,
652        F: Fn(&mut T, &WlTouchRef, i32, Fixed, Fixed),
653    {
654        type Data = T;
655
656        #[inline]
657        fn shape(&self, _data: &mut T, _slf: &WlTouchRef, id: i32, major: Fixed, minor: Fixed) {
658            self.0(_data, _slf, id, major, minor)
659        }
660    }
661
662    /// Event handler for orientation events.
663    pub struct Orientation<T, F>(F, PhantomData<fn(&mut T)>);
664    impl<T, F> WlTouchEventHandler for Orientation<T, F>
665    where
666        T: 'static,
667        F: Fn(&mut T, &WlTouchRef, i32, Fixed),
668    {
669        type Data = T;
670
671        #[inline]
672        fn orientation(&self, _data: &mut T, _slf: &WlTouchRef, id: i32, orientation: Fixed) {
673            self.0(_data, _slf, id, orientation)
674        }
675    }
676
677    impl WlTouch {
678        /// Creates an event handler for down events.
679        ///
680        /// The event handler ignores all other events.
681        #[allow(dead_code)]
682        pub fn on_down<T, F>(f: F) -> Down<T, F>
683        where
684            T: 'static,
685            F: Fn(&mut T, &WlTouchRef, u32, u32, Option<&WlSurfaceRef>, i32, Fixed, Fixed),
686        {
687            Down(f, PhantomData)
688        }
689
690        /// Creates an event handler for up events.
691        ///
692        /// The event handler ignores all other events.
693        #[allow(dead_code)]
694        pub fn on_up<T, F>(f: F) -> Up<T, F>
695        where
696            T: 'static,
697            F: Fn(&mut T, &WlTouchRef, u32, u32, i32),
698        {
699            Up(f, PhantomData)
700        }
701
702        /// Creates an event handler for motion events.
703        ///
704        /// The event handler ignores all other events.
705        #[allow(dead_code)]
706        pub fn on_motion<T, F>(f: F) -> Motion<T, F>
707        where
708            T: 'static,
709            F: Fn(&mut T, &WlTouchRef, u32, i32, Fixed, Fixed),
710        {
711            Motion(f, PhantomData)
712        }
713
714        /// Creates an event handler for frame events.
715        ///
716        /// The event handler ignores all other events.
717        #[allow(dead_code)]
718        pub fn on_frame<T, F>(f: F) -> Frame<T, F>
719        where
720            T: 'static,
721            F: Fn(&mut T, &WlTouchRef),
722        {
723            Frame(f, PhantomData)
724        }
725
726        /// Creates an event handler for cancel events.
727        ///
728        /// The event handler ignores all other events.
729        #[allow(dead_code)]
730        pub fn on_cancel<T, F>(f: F) -> Cancel<T, F>
731        where
732            T: 'static,
733            F: Fn(&mut T, &WlTouchRef),
734        {
735            Cancel(f, PhantomData)
736        }
737
738        /// Creates an event handler for shape events.
739        ///
740        /// The event handler ignores all other events.
741        #[allow(dead_code)]
742        pub fn on_shape<T, F>(f: F) -> Shape<T, F>
743        where
744            T: 'static,
745            F: Fn(&mut T, &WlTouchRef, i32, Fixed, Fixed),
746        {
747            Shape(f, PhantomData)
748        }
749
750        /// Creates an event handler for orientation events.
751        ///
752        /// The event handler ignores all other events.
753        #[allow(dead_code)]
754        pub fn on_orientation<T, F>(f: F) -> Orientation<T, F>
755        where
756            T: 'static,
757            F: Fn(&mut T, &WlTouchRef, i32, Fixed),
758        {
759            Orientation(f, PhantomData)
760        }
761    }
762}