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