Skip to main content

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