poll_integration/common/protocols/tablet_v2/zwp_tablet_tool_v2.rs
1//! a physical tablet tool
2//!
3//! An object that represents a physical tool that has been, or is
4//! currently in use with a tablet in this seat. Each wp_tablet_tool
5//! object stays valid until the client destroys it; the compositor
6//! reuses the wp_tablet_tool object to indicate that the object's
7//! respective physical tool has come into proximity of a tablet again.
8//!
9//! A wp_tablet_tool object's relation to a physical tool depends on the
10//! tablet's ability to report serial numbers. If the tablet supports
11//! this capability, then the object represents a specific physical tool
12//! and can be identified even when used on multiple tablets.
13//!
14//! A tablet tool has a number of static characteristics, e.g. tool type,
15//! hardware_serial and capabilities. These capabilities are sent in an
16//! event sequence after the wp_tablet_seat.tool_added event before any
17//! actual events from this tool. This initial event sequence is
18//! terminated by a wp_tablet_tool.done event.
19//!
20//! Tablet tool events are grouped by wp_tablet_tool.frame events.
21//! Any events received before a wp_tablet_tool.frame event should be
22//! considered part of the same hardware state change.
23
24use {super::super::all_types::*, ::wl_client::builder::prelude::*};
25
26static INTERFACE: wl_interface = wl_interface {
27 name: c"zwp_tablet_tool_v2".as_ptr(),
28 version: 1,
29 method_count: 2,
30 methods: {
31 static MESSAGES: [wl_message; 2] = [
32 wl_message {
33 name: c"set_cursor".as_ptr(),
34 signature: c"u?oii".as_ptr(),
35 types: {
36 static TYPES: [Option<&'static wl_interface>; 4] =
37 [None, Some(WlSurface::WL_INTERFACE), None, None];
38 TYPES.as_ptr().cast()
39 },
40 },
41 wl_message {
42 name: c"destroy".as_ptr(),
43 signature: c"".as_ptr(),
44 types: {
45 static TYPES: [Option<&'static wl_interface>; 0] = [];
46 TYPES.as_ptr().cast()
47 },
48 },
49 ];
50 MESSAGES.as_ptr()
51 },
52 event_count: 19,
53 events: {
54 static MESSAGES: [wl_message; 19] = [
55 wl_message {
56 name: c"type".as_ptr(),
57 signature: c"u".as_ptr(),
58 types: {
59 static TYPES: [Option<&'static wl_interface>; 1] = [None];
60 TYPES.as_ptr().cast()
61 },
62 },
63 wl_message {
64 name: c"hardware_serial".as_ptr(),
65 signature: c"uu".as_ptr(),
66 types: {
67 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
68 TYPES.as_ptr().cast()
69 },
70 },
71 wl_message {
72 name: c"hardware_id_wacom".as_ptr(),
73 signature: c"uu".as_ptr(),
74 types: {
75 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
76 TYPES.as_ptr().cast()
77 },
78 },
79 wl_message {
80 name: c"capability".as_ptr(),
81 signature: c"u".as_ptr(),
82 types: {
83 static TYPES: [Option<&'static wl_interface>; 1] = [None];
84 TYPES.as_ptr().cast()
85 },
86 },
87 wl_message {
88 name: c"done".as_ptr(),
89 signature: c"".as_ptr(),
90 types: {
91 static TYPES: [Option<&'static wl_interface>; 0] = [];
92 TYPES.as_ptr().cast()
93 },
94 },
95 wl_message {
96 name: c"removed".as_ptr(),
97 signature: c"".as_ptr(),
98 types: {
99 static TYPES: [Option<&'static wl_interface>; 0] = [];
100 TYPES.as_ptr().cast()
101 },
102 },
103 wl_message {
104 name: c"proximity_in".as_ptr(),
105 signature: c"uoo".as_ptr(),
106 types: {
107 static TYPES: [Option<&'static wl_interface>; 3] = [
108 None,
109 Some(ZwpTabletV2::WL_INTERFACE),
110 Some(WlSurface::WL_INTERFACE),
111 ];
112 TYPES.as_ptr().cast()
113 },
114 },
115 wl_message {
116 name: c"proximity_out".as_ptr(),
117 signature: c"".as_ptr(),
118 types: {
119 static TYPES: [Option<&'static wl_interface>; 0] = [];
120 TYPES.as_ptr().cast()
121 },
122 },
123 wl_message {
124 name: c"down".as_ptr(),
125 signature: c"u".as_ptr(),
126 types: {
127 static TYPES: [Option<&'static wl_interface>; 1] = [None];
128 TYPES.as_ptr().cast()
129 },
130 },
131 wl_message {
132 name: c"up".as_ptr(),
133 signature: c"".as_ptr(),
134 types: {
135 static TYPES: [Option<&'static wl_interface>; 0] = [];
136 TYPES.as_ptr().cast()
137 },
138 },
139 wl_message {
140 name: c"motion".as_ptr(),
141 signature: c"ff".as_ptr(),
142 types: {
143 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
144 TYPES.as_ptr().cast()
145 },
146 },
147 wl_message {
148 name: c"pressure".as_ptr(),
149 signature: c"u".as_ptr(),
150 types: {
151 static TYPES: [Option<&'static wl_interface>; 1] = [None];
152 TYPES.as_ptr().cast()
153 },
154 },
155 wl_message {
156 name: c"distance".as_ptr(),
157 signature: c"u".as_ptr(),
158 types: {
159 static TYPES: [Option<&'static wl_interface>; 1] = [None];
160 TYPES.as_ptr().cast()
161 },
162 },
163 wl_message {
164 name: c"tilt".as_ptr(),
165 signature: c"ff".as_ptr(),
166 types: {
167 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
168 TYPES.as_ptr().cast()
169 },
170 },
171 wl_message {
172 name: c"rotation".as_ptr(),
173 signature: c"f".as_ptr(),
174 types: {
175 static TYPES: [Option<&'static wl_interface>; 1] = [None];
176 TYPES.as_ptr().cast()
177 },
178 },
179 wl_message {
180 name: c"slider".as_ptr(),
181 signature: c"i".as_ptr(),
182 types: {
183 static TYPES: [Option<&'static wl_interface>; 1] = [None];
184 TYPES.as_ptr().cast()
185 },
186 },
187 wl_message {
188 name: c"wheel".as_ptr(),
189 signature: c"fi".as_ptr(),
190 types: {
191 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
192 TYPES.as_ptr().cast()
193 },
194 },
195 wl_message {
196 name: c"button".as_ptr(),
197 signature: c"uuu".as_ptr(),
198 types: {
199 static TYPES: [Option<&'static wl_interface>; 3] = [None, None, None];
200 TYPES.as_ptr().cast()
201 },
202 },
203 wl_message {
204 name: c"frame".as_ptr(),
205 signature: c"u".as_ptr(),
206 types: {
207 static TYPES: [Option<&'static wl_interface>; 1] = [None];
208 TYPES.as_ptr().cast()
209 },
210 },
211 ];
212 MESSAGES.as_ptr()
213 },
214};
215
216/// An owned zwp_tablet_tool_v2 proxy.
217///
218/// See the documentation of [the module][self] for the interface description.
219#[derive(Clone, Eq, PartialEq)]
220#[repr(transparent)]
221pub struct ZwpTabletToolV2 {
222 /// This proxy has the interface INTERFACE.
223 proxy: UntypedOwnedProxy,
224}
225
226/// A borrowed zwp_tablet_tool_v2 proxy.
227///
228/// See the documentation of [the module][self] for the interface description.
229#[derive(Eq, PartialEq)]
230#[repr(transparent)]
231pub struct ZwpTabletToolV2Ref {
232 /// This proxy has the interface INTERFACE.
233 proxy: UntypedBorrowedProxy,
234}
235
236// SAFETY: ZwpTabletToolV2 is a transparent wrapper around UntypedOwnedProxy
237unsafe impl UntypedOwnedProxyWrapper for ZwpTabletToolV2 {}
238
239// SAFETY: - INTERFACE is a valid wl_interface
240// - The only invariant is that self.proxy has a compatible interface
241unsafe impl OwnedProxy for ZwpTabletToolV2 {
242 const INTERFACE: &'static str = "zwp_tablet_tool_v2";
243 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
244 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
245 private::EventHandler(private::NoOpEventHandler);
246 const MAX_VERSION: u32 = 1;
247
248 type Borrowed = ZwpTabletToolV2Ref;
249 type Api = private::ProxyApi;
250 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
251}
252
253// SAFETY: ZwpTabletToolV2Ref is a transparent wrapper around UntypedBorrowedProxy
254unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletToolV2Ref {}
255
256// SAFETY: - The only invariant is that self.proxy has a compatible interface
257unsafe impl BorrowedProxy for ZwpTabletToolV2Ref {
258 type Owned = ZwpTabletToolV2;
259}
260
261impl Deref for ZwpTabletToolV2 {
262 type Target = ZwpTabletToolV2Ref;
263
264 fn deref(&self) -> &Self::Target {
265 proxy::low_level::deref(self)
266 }
267}
268
269mod private {
270 pub struct ProxyApi;
271
272 #[allow(dead_code)]
273 pub struct EventHandler<H>(pub(super) H);
274
275 #[allow(dead_code)]
276 pub struct NoOpEventHandler;
277}
278
279impl Debug for ZwpTabletToolV2 {
280 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
281 write!(f, "zwp_tablet_tool_v2#{}", self.proxy.id())
282 }
283}
284
285impl Debug for ZwpTabletToolV2Ref {
286 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
287 write!(f, "zwp_tablet_tool_v2#{}", self.proxy.id())
288 }
289}
290
291impl PartialEq<ZwpTabletToolV2Ref> for ZwpTabletToolV2 {
292 fn eq(&self, other: &ZwpTabletToolV2Ref) -> bool {
293 self.proxy == other.proxy
294 }
295}
296
297impl PartialEq<ZwpTabletToolV2> for ZwpTabletToolV2Ref {
298 fn eq(&self, other: &ZwpTabletToolV2) -> bool {
299 self.proxy == other.proxy
300 }
301}
302
303#[allow(dead_code)]
304impl ZwpTabletToolV2 {
305 /// Since when the destroy request is available.
306 #[allow(dead_code)]
307 pub const REQ__DESTROY__SINCE: u32 = 1;
308
309 /// destroy the tool object
310 ///
311 /// This destroys the client's resource for this tool object.
312 #[inline]
313 pub fn destroy(&self) {
314 let mut args = [];
315 // SAFETY: - self.proxy has the interface INTERFACE
316 // - 1 < INTERFACE.method_count = 2
317 // - the request signature is ``
318 unsafe {
319 self.proxy.send_destructor(1, &mut args);
320 }
321 }
322}
323
324#[allow(dead_code)]
325impl ZwpTabletToolV2Ref {
326 /// set the tablet tool's surface
327 ///
328 /// Sets the surface of the cursor used for this tool on the given
329 /// tablet. This request only takes effect if the tool is in proximity
330 /// of one of the requesting client's surfaces or the surface parameter
331 /// is the current pointer surface. If there was a previous surface set
332 /// with this request it is replaced. If surface is NULL, the cursor
333 /// image is hidden.
334 ///
335 /// The parameters hotspot_x and hotspot_y define the position of the
336 /// pointer surface relative to the pointer location. Its top-left corner
337 /// is always at (x, y) - (hotspot_x, hotspot_y), where (x, y) are the
338 /// coordinates of the pointer location, in surface-local coordinates.
339 ///
340 /// On surface.attach requests to the pointer surface, hotspot_x and
341 /// hotspot_y are decremented by the x and y parameters passed to the
342 /// request. Attach must be confirmed by wl_surface.commit as usual.
343 ///
344 /// The hotspot can also be updated by passing the currently set pointer
345 /// surface to this request with new values for hotspot_x and hotspot_y.
346 ///
347 /// The current and pending input regions of the wl_surface are cleared,
348 /// and wl_surface.set_input_region is ignored until the wl_surface is no
349 /// longer used as the cursor. When the use as a cursor ends, the current
350 /// and pending input regions become undefined, and the wl_surface is
351 /// unmapped.
352 ///
353 /// This request gives the surface the role of a wp_tablet_tool cursor. A
354 /// surface may only ever be used as the cursor surface for one
355 /// wp_tablet_tool. If the surface already has another role or has
356 /// previously been used as cursor surface for a different tool, a
357 /// protocol error is raised.
358 ///
359 /// # Arguments
360 ///
361 /// - `serial`: serial of the proximity_in event
362 /// - `surface`:
363 /// - `hotspot_x`: surface-local x coordinate
364 /// - `hotspot_y`: surface-local y coordinate
365 #[inline]
366 pub fn set_cursor(
367 &self,
368 serial: u32,
369 surface: Option<&WlSurfaceRef>,
370 hotspot_x: i32,
371 hotspot_y: i32,
372 ) {
373 let (arg0, arg1, arg2, arg3) = (serial, surface, hotspot_x, hotspot_y);
374 let obj1_lock = arg1.map(|arg1| proxy::lock(arg1));
375 let obj1 = obj1_lock
376 .map(|obj1_lock| check_argument_proxy("surface", obj1_lock.wl_proxy()))
377 .unwrap_or(ptr::null_mut());
378 let mut args = [
379 wl_argument { u: arg0 },
380 wl_argument { o: obj1 },
381 wl_argument { i: arg2 },
382 wl_argument { i: arg3 },
383 ];
384 // SAFETY: - self.proxy has the interface INTERFACE
385 // - 0 < INTERFACE.method_count = 2
386 // - the request signature is `u?oii`
387 unsafe {
388 self.proxy.send_request(0, &mut args);
389 }
390 }
391}
392
393impl ZwpTabletToolV2 {
394 /// Since when the type event is available.
395 #[allow(dead_code)]
396 pub const EVT__TYPE__SINCE: u32 = 1;
397
398 /// Since when the hardware_serial event is available.
399 #[allow(dead_code)]
400 pub const EVT__HARDWARE_SERIAL__SINCE: u32 = 1;
401
402 /// Since when the hardware_id_wacom event is available.
403 #[allow(dead_code)]
404 pub const EVT__HARDWARE_ID_WACOM__SINCE: u32 = 1;
405
406 /// Since when the capability event is available.
407 #[allow(dead_code)]
408 pub const EVT__CAPABILITY__SINCE: u32 = 1;
409
410 /// Since when the done event is available.
411 #[allow(dead_code)]
412 pub const EVT__DONE__SINCE: u32 = 1;
413
414 /// Since when the removed event is available.
415 #[allow(dead_code)]
416 pub const EVT__REMOVED__SINCE: u32 = 1;
417
418 /// Since when the proximity_in event is available.
419 #[allow(dead_code)]
420 pub const EVT__PROXIMITY_IN__SINCE: u32 = 1;
421
422 /// Since when the proximity_out event is available.
423 #[allow(dead_code)]
424 pub const EVT__PROXIMITY_OUT__SINCE: u32 = 1;
425
426 /// Since when the down event is available.
427 #[allow(dead_code)]
428 pub const EVT__DOWN__SINCE: u32 = 1;
429
430 /// Since when the up event is available.
431 #[allow(dead_code)]
432 pub const EVT__UP__SINCE: u32 = 1;
433
434 /// Since when the motion event is available.
435 #[allow(dead_code)]
436 pub const EVT__MOTION__SINCE: u32 = 1;
437
438 /// Since when the pressure event is available.
439 #[allow(dead_code)]
440 pub const EVT__PRESSURE__SINCE: u32 = 1;
441
442 /// Since when the distance event is available.
443 #[allow(dead_code)]
444 pub const EVT__DISTANCE__SINCE: u32 = 1;
445
446 /// Since when the tilt event is available.
447 #[allow(dead_code)]
448 pub const EVT__TILT__SINCE: u32 = 1;
449
450 /// Since when the rotation event is available.
451 #[allow(dead_code)]
452 pub const EVT__ROTATION__SINCE: u32 = 1;
453
454 /// Since when the slider event is available.
455 #[allow(dead_code)]
456 pub const EVT__SLIDER__SINCE: u32 = 1;
457
458 /// Since when the wheel event is available.
459 #[allow(dead_code)]
460 pub const EVT__WHEEL__SINCE: u32 = 1;
461
462 /// Since when the button event is available.
463 #[allow(dead_code)]
464 pub const EVT__BUTTON__SINCE: u32 = 1;
465
466 /// Since when the frame event is available.
467 #[allow(dead_code)]
468 pub const EVT__FRAME__SINCE: u32 = 1;
469}
470
471/// An event handler for [ZwpTabletToolV2] proxies.
472#[allow(dead_code)]
473pub trait ZwpTabletToolV2EventHandler {
474 /// tool type
475 ///
476 /// The tool type is the high-level type of the tool and usually decides
477 /// the interaction expected from this tool.
478 ///
479 /// This event is sent in the initial burst of events before the
480 /// wp_tablet_tool.done event.
481 ///
482 /// # Arguments
483 ///
484 /// - `tool_type`: the physical tool type
485 #[inline]
486 fn r#type(&self, _slf: &ZwpTabletToolV2Ref, tool_type: ZwpTabletToolV2Type) {
487 let _ = tool_type;
488 }
489
490 /// unique hardware serial number of the tool
491 ///
492 /// If the physical tool can be identified by a unique 64-bit serial
493 /// number, this event notifies the client of this serial number.
494 ///
495 /// If multiple tablets are available in the same seat and the tool is
496 /// uniquely identifiable by the serial number, that tool may move
497 /// between tablets.
498 ///
499 /// Otherwise, if the tool has no serial number and this event is
500 /// missing, the tool is tied to the tablet it first comes into
501 /// proximity with. Even if the physical tool is used on multiple
502 /// tablets, separate wp_tablet_tool objects will be created, one per
503 /// tablet.
504 ///
505 /// This event is sent in the initial burst of events before the
506 /// wp_tablet_tool.done event.
507 ///
508 /// # Arguments
509 ///
510 /// - `hardware_serial_hi`: the unique serial number of the tool, most significant bits
511 /// - `hardware_serial_lo`: the unique serial number of the tool, least significant bits
512 #[inline]
513 fn hardware_serial(
514 &self,
515 _slf: &ZwpTabletToolV2Ref,
516 hardware_serial_hi: u32,
517 hardware_serial_lo: u32,
518 ) {
519 let _ = hardware_serial_hi;
520 let _ = hardware_serial_lo;
521 }
522
523 /// hardware id notification in Wacom's format
524 ///
525 /// This event notifies the client of a hardware id available on this tool.
526 ///
527 /// The hardware id is a device-specific 64-bit id that provides extra
528 /// information about the tool in use, beyond the wl_tool.type
529 /// enumeration. The format of the id is specific to tablets made by
530 /// Wacom Inc. For example, the hardware id of a Wacom Grip
531 /// Pen (a stylus) is 0x802.
532 ///
533 /// This event is sent in the initial burst of events before the
534 /// wp_tablet_tool.done event.
535 ///
536 /// # Arguments
537 ///
538 /// - `hardware_id_hi`: the hardware id, most significant bits
539 /// - `hardware_id_lo`: the hardware id, least significant bits
540 #[inline]
541 fn hardware_id_wacom(
542 &self,
543 _slf: &ZwpTabletToolV2Ref,
544 hardware_id_hi: u32,
545 hardware_id_lo: u32,
546 ) {
547 let _ = hardware_id_hi;
548 let _ = hardware_id_lo;
549 }
550
551 /// tool capability notification
552 ///
553 /// This event notifies the client of any capabilities of this tool,
554 /// beyond the main set of x/y axes and tip up/down detection.
555 ///
556 /// One event is sent for each extra capability available on this tool.
557 ///
558 /// This event is sent in the initial burst of events before the
559 /// wp_tablet_tool.done event.
560 ///
561 /// # Arguments
562 ///
563 /// - `capability`: the capability
564 #[inline]
565 fn capability(&self, _slf: &ZwpTabletToolV2Ref, capability: ZwpTabletToolV2Capability) {
566 let _ = capability;
567 }
568
569 /// tool description events sequence complete
570 ///
571 /// This event signals the end of the initial burst of descriptive
572 /// events. A client may consider the static description of the tool to
573 /// be complete and finalize initialization of the tool.
574 #[inline]
575 fn done(&self, _slf: &ZwpTabletToolV2Ref) {}
576
577 /// tool removed
578 ///
579 /// This event is sent when the tool is removed from the system and will
580 /// send no further events. Should the physical tool come back into
581 /// proximity later, a new wp_tablet_tool object will be created.
582 ///
583 /// It is compositor-dependent when a tool is removed. A compositor may
584 /// remove a tool on proximity out, tablet removal or any other reason.
585 /// A compositor may also keep a tool alive until shutdown.
586 ///
587 /// If the tool is currently in proximity, a proximity_out event will be
588 /// sent before the removed event. See wp_tablet_tool.proximity_out for
589 /// the handling of any buttons logically down.
590 ///
591 /// When this event is received, the client must wp_tablet_tool.destroy
592 /// the object.
593 #[inline]
594 fn removed(&self, _slf: &ZwpTabletToolV2Ref) {}
595
596 /// proximity in event
597 ///
598 /// Notification that this tool is focused on a certain surface.
599 ///
600 /// This event can be received when the tool has moved from one surface to
601 /// another, or when the tool has come back into proximity above the
602 /// surface.
603 ///
604 /// If any button is logically down when the tool comes into proximity,
605 /// the respective button event is sent after the proximity_in event but
606 /// within the same frame as the proximity_in event.
607 ///
608 /// # Arguments
609 ///
610 /// - `serial`:
611 /// - `tablet`: The tablet the tool is in proximity of
612 /// - `surface`: The current surface the tablet tool is over
613 ///
614 /// All borrowed proxies passed to this function are guaranteed to be
615 /// immutable and non-null.
616 #[inline]
617 fn proximity_in(
618 &self,
619 _slf: &ZwpTabletToolV2Ref,
620 serial: u32,
621 tablet: Option<&ZwpTabletV2Ref>,
622 surface: Option<&WlSurfaceRef>,
623 ) {
624 let _ = serial;
625 let _ = tablet;
626 let _ = surface;
627 }
628
629 /// proximity out event
630 ///
631 /// Notification that this tool has either left proximity, or is no
632 /// longer focused on a certain surface.
633 ///
634 /// When the tablet tool leaves proximity of the tablet, button release
635 /// events are sent for each button that was held down at the time of
636 /// leaving proximity. These events are sent before the proximity_out
637 /// event but within the same wp_tablet.frame.
638 ///
639 /// If the tool stays within proximity of the tablet, but the focus
640 /// changes from one surface to another, a button release event may not
641 /// be sent until the button is actually released or the tool leaves the
642 /// proximity of the tablet.
643 #[inline]
644 fn proximity_out(&self, _slf: &ZwpTabletToolV2Ref) {}
645
646 /// tablet tool is making contact
647 ///
648 /// Sent whenever the tablet tool comes in contact with the surface of the
649 /// tablet.
650 ///
651 /// If the tool is already in contact with the tablet when entering the
652 /// input region, the client owning said region will receive a
653 /// wp_tablet.proximity_in event, followed by a wp_tablet.down
654 /// event and a wp_tablet.frame event.
655 ///
656 /// Note that this event describes logical contact, not physical
657 /// contact. On some devices, a compositor may not consider a tool in
658 /// logical contact until a minimum physical pressure threshold is
659 /// exceeded.
660 ///
661 /// # Arguments
662 ///
663 /// - `serial`:
664 #[inline]
665 fn down(&self, _slf: &ZwpTabletToolV2Ref, serial: u32) {
666 let _ = serial;
667 }
668
669 /// tablet tool is no longer making contact
670 ///
671 /// Sent whenever the tablet tool stops making contact with the surface of
672 /// the tablet, or when the tablet tool moves out of the input region
673 /// and the compositor grab (if any) is dismissed.
674 ///
675 /// If the tablet tool moves out of the input region while in contact
676 /// with the surface of the tablet and the compositor does not have an
677 /// ongoing grab on the surface, the client owning said region will
678 /// receive a wp_tablet.up event, followed by a wp_tablet.proximity_out
679 /// event and a wp_tablet.frame event. If the compositor has an ongoing
680 /// grab on this device, this event sequence is sent whenever the grab
681 /// is dismissed in the future.
682 ///
683 /// Note that this event describes logical contact, not physical
684 /// contact. On some devices, a compositor may not consider a tool out
685 /// of logical contact until physical pressure falls below a specific
686 /// threshold.
687 #[inline]
688 fn up(&self, _slf: &ZwpTabletToolV2Ref) {}
689
690 /// motion event
691 ///
692 /// Sent whenever a tablet tool moves.
693 ///
694 /// # Arguments
695 ///
696 /// - `x`: surface-local x coordinate
697 /// - `y`: surface-local y coordinate
698 #[inline]
699 fn motion(&self, _slf: &ZwpTabletToolV2Ref, x: Fixed, y: Fixed) {
700 let _ = x;
701 let _ = y;
702 }
703
704 /// pressure change event
705 ///
706 /// Sent whenever the pressure axis on a tool changes. The value of this
707 /// event is normalized to a value between 0 and 65535.
708 ///
709 /// Note that pressure may be nonzero even when a tool is not in logical
710 /// contact. See the down and up events for more details.
711 ///
712 /// # Arguments
713 ///
714 /// - `pressure`: The current pressure value
715 #[inline]
716 fn pressure(&self, _slf: &ZwpTabletToolV2Ref, pressure: u32) {
717 let _ = pressure;
718 }
719
720 /// distance change event
721 ///
722 /// Sent whenever the distance axis on a tool changes. The value of this
723 /// event is normalized to a value between 0 and 65535.
724 ///
725 /// Note that distance may be nonzero even when a tool is not in logical
726 /// contact. See the down and up events for more details.
727 ///
728 /// # Arguments
729 ///
730 /// - `distance`: The current distance value
731 #[inline]
732 fn distance(&self, _slf: &ZwpTabletToolV2Ref, distance: u32) {
733 let _ = distance;
734 }
735
736 /// tilt change event
737 ///
738 /// Sent whenever one or both of the tilt axes on a tool change. Each tilt
739 /// value is in degrees, relative to the z-axis of the tablet.
740 /// The angle is positive when the top of a tool tilts along the
741 /// positive x or y axis.
742 ///
743 /// # Arguments
744 ///
745 /// - `tilt_x`: The current value of the X tilt axis
746 /// - `tilt_y`: The current value of the Y tilt axis
747 #[inline]
748 fn tilt(&self, _slf: &ZwpTabletToolV2Ref, tilt_x: Fixed, tilt_y: Fixed) {
749 let _ = tilt_x;
750 let _ = tilt_y;
751 }
752
753 /// z-rotation change event
754 ///
755 /// Sent whenever the z-rotation axis on the tool changes. The
756 /// rotation value is in degrees clockwise from the tool's
757 /// logical neutral position.
758 ///
759 /// # Arguments
760 ///
761 /// - `degrees`: The current rotation of the Z axis
762 #[inline]
763 fn rotation(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed) {
764 let _ = degrees;
765 }
766
767 /// Slider position change event
768 ///
769 /// Sent whenever the slider position on the tool changes. The
770 /// value is normalized between -65535 and 65535, with 0 as the logical
771 /// neutral position of the slider.
772 ///
773 /// The slider is available on e.g. the Wacom Airbrush tool.
774 ///
775 /// # Arguments
776 ///
777 /// - `position`: The current position of slider
778 #[inline]
779 fn slider(&self, _slf: &ZwpTabletToolV2Ref, position: i32) {
780 let _ = position;
781 }
782
783 /// Wheel delta event
784 ///
785 /// Sent whenever the wheel on the tool emits an event. This event
786 /// contains two values for the same axis change. The degrees value is
787 /// in the same orientation as the wl_pointer.vertical_scroll axis. The
788 /// clicks value is in discrete logical clicks of the mouse wheel. This
789 /// value may be zero if the movement of the wheel was less
790 /// than one logical click.
791 ///
792 /// Clients should choose either value and avoid mixing degrees and
793 /// clicks. The compositor may accumulate values smaller than a logical
794 /// click and emulate click events when a certain threshold is met.
795 /// Thus, wl_tablet_tool.wheel events with non-zero clicks values may
796 /// have different degrees values.
797 ///
798 /// # Arguments
799 ///
800 /// - `degrees`: The wheel delta in degrees
801 /// - `clicks`: The wheel delta in discrete clicks
802 #[inline]
803 fn wheel(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed, clicks: i32) {
804 let _ = degrees;
805 let _ = clicks;
806 }
807
808 /// button event
809 ///
810 /// Sent whenever a button on the tool is pressed or released.
811 ///
812 /// If a button is held down when the tool moves in or out of proximity,
813 /// button events are generated by the compositor. See
814 /// wp_tablet_tool.proximity_in and wp_tablet_tool.proximity_out for
815 /// details.
816 ///
817 /// # Arguments
818 ///
819 /// - `serial`:
820 /// - `button`: The button whose state has changed
821 /// - `state`: Whether the button was pressed or released
822 #[inline]
823 fn button(
824 &self,
825 _slf: &ZwpTabletToolV2Ref,
826 serial: u32,
827 button: u32,
828 state: ZwpTabletToolV2ButtonState,
829 ) {
830 let _ = serial;
831 let _ = button;
832 let _ = state;
833 }
834
835 /// frame event
836 ///
837 /// Marks the end of a series of axis and/or button updates from the
838 /// tablet. The Wayland protocol requires axis updates to be sent
839 /// sequentially, however all events within a frame should be considered
840 /// one hardware event.
841 ///
842 /// # Arguments
843 ///
844 /// - `time`: The time of the event with millisecond granularity
845 #[inline]
846 fn frame(&self, _slf: &ZwpTabletToolV2Ref, time: u32) {
847 let _ = time;
848 }
849}
850
851impl ZwpTabletToolV2EventHandler for private::NoOpEventHandler {}
852
853// SAFETY: INTERFACE is a valid wl_interface
854unsafe impl<H> EventHandler for private::EventHandler<H>
855where
856 H: ZwpTabletToolV2EventHandler,
857{
858 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
859
860 #[allow(unused_variables)]
861 unsafe fn handle_event(
862 &self,
863 queue: &Queue,
864 slf: &UntypedBorrowedProxy,
865 opcode: u32,
866 args: *mut wl_argument,
867 ) {
868 // SAFETY: This function required that slf has the interface INTERFACE
869 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<ZwpTabletToolV2Ref>(slf) };
870 match opcode {
871 0 => {
872 // SAFETY: INTERFACE requires that there are 1 arguments
873 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
874 // SAFETY: - INTERFACE requires that args[0] contains a uint
875 let arg0 = unsafe { ZwpTabletToolV2Type(args[0].u) };
876 self.0.r#type(slf, arg0);
877 }
878 1 => {
879 // SAFETY: INTERFACE requires that there are 2 arguments
880 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
881 // SAFETY: - INTERFACE requires that args[0] contains a uint
882 let arg0 = unsafe { args[0].u };
883 // SAFETY: - INTERFACE requires that args[1] contains a uint
884 let arg1 = unsafe { args[1].u };
885 self.0.hardware_serial(slf, arg0, arg1);
886 }
887 2 => {
888 // SAFETY: INTERFACE requires that there are 2 arguments
889 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
890 // SAFETY: - INTERFACE requires that args[0] contains a uint
891 let arg0 = unsafe { args[0].u };
892 // SAFETY: - INTERFACE requires that args[1] contains a uint
893 let arg1 = unsafe { args[1].u };
894 self.0.hardware_id_wacom(slf, arg0, arg1);
895 }
896 3 => {
897 // SAFETY: INTERFACE requires that there are 1 arguments
898 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
899 // SAFETY: - INTERFACE requires that args[0] contains a uint
900 let arg0 = unsafe { ZwpTabletToolV2Capability(args[0].u) };
901 self.0.capability(slf, arg0);
902 }
903 4 => {
904 self.0.done(slf);
905 }
906 5 => {
907 self.0.removed(slf);
908 }
909 6 => {
910 // SAFETY: INTERFACE requires that there are 3 arguments
911 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
912 // SAFETY: - INTERFACE requires that args[0] contains a uint
913 let arg0 = unsafe { args[0].u };
914 // SAFETY: - INTERFACE requires that args[1] contains an object
915 let arg1 = unsafe {
916 if let Some(p) = NonNull::new(args[1].o.cast()) {
917 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
918 } else {
919 None
920 }
921 };
922 // SAFETY: - INTERFACE requires that the object has the interface ZwpTabletV2::WL_INTERFACE
923 let arg1 = arg1.as_ref().map(|arg1| unsafe {
924 proxy::low_level::from_untyped_borrowed::<ZwpTabletV2Ref>(arg1)
925 });
926 // SAFETY: - INTERFACE requires that args[2] contains an object
927 let arg2 = unsafe {
928 if let Some(p) = NonNull::new(args[2].o.cast()) {
929 Some(UntypedBorrowedProxy::new_immutable(queue.libwayland(), p))
930 } else {
931 None
932 }
933 };
934 // SAFETY: - INTERFACE requires that the object has the interface WlSurface::WL_INTERFACE
935 let arg2 = arg2.as_ref().map(|arg2| unsafe {
936 proxy::low_level::from_untyped_borrowed::<WlSurfaceRef>(arg2)
937 });
938 self.0.proximity_in(slf, arg0, arg1, arg2);
939 }
940 7 => {
941 self.0.proximity_out(slf);
942 }
943 8 => {
944 // SAFETY: INTERFACE requires that there are 1 arguments
945 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
946 // SAFETY: - INTERFACE requires that args[0] contains a uint
947 let arg0 = unsafe { args[0].u };
948 self.0.down(slf, arg0);
949 }
950 9 => {
951 self.0.up(slf);
952 }
953 10 => {
954 // SAFETY: INTERFACE requires that there are 2 arguments
955 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
956 // SAFETY: - INTERFACE requires that args[0] contains a fixed
957 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
958 // SAFETY: - INTERFACE requires that args[1] contains a fixed
959 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
960 self.0.motion(slf, arg0, arg1);
961 }
962 11 => {
963 // SAFETY: INTERFACE requires that there are 1 arguments
964 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
965 // SAFETY: - INTERFACE requires that args[0] contains a uint
966 let arg0 = unsafe { args[0].u };
967 self.0.pressure(slf, arg0);
968 }
969 12 => {
970 // SAFETY: INTERFACE requires that there are 1 arguments
971 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
972 // SAFETY: - INTERFACE requires that args[0] contains a uint
973 let arg0 = unsafe { args[0].u };
974 self.0.distance(slf, arg0);
975 }
976 13 => {
977 // SAFETY: INTERFACE requires that there are 2 arguments
978 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
979 // SAFETY: - INTERFACE requires that args[0] contains a fixed
980 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
981 // SAFETY: - INTERFACE requires that args[1] contains a fixed
982 let arg1 = unsafe { Fixed::from_wire(args[1].f) };
983 self.0.tilt(slf, arg0, arg1);
984 }
985 14 => {
986 // SAFETY: INTERFACE requires that there are 1 arguments
987 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
988 // SAFETY: - INTERFACE requires that args[0] contains a fixed
989 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
990 self.0.rotation(slf, arg0);
991 }
992 15 => {
993 // SAFETY: INTERFACE requires that there are 1 arguments
994 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
995 // SAFETY: - INTERFACE requires that args[0] contains an int
996 let arg0 = unsafe { args[0].i };
997 self.0.slider(slf, arg0);
998 }
999 16 => {
1000 // SAFETY: INTERFACE requires that there are 2 arguments
1001 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
1002 // SAFETY: - INTERFACE requires that args[0] contains a fixed
1003 let arg0 = unsafe { Fixed::from_wire(args[0].f) };
1004 // SAFETY: - INTERFACE requires that args[1] contains an int
1005 let arg1 = unsafe { args[1].i };
1006 self.0.wheel(slf, arg0, arg1);
1007 }
1008 17 => {
1009 // SAFETY: INTERFACE requires that there are 3 arguments
1010 let args = unsafe { &*args.cast::<[wl_argument; 3]>() };
1011 // SAFETY: - INTERFACE requires that args[0] contains a uint
1012 let arg0 = unsafe { args[0].u };
1013 // SAFETY: - INTERFACE requires that args[1] contains a uint
1014 let arg1 = unsafe { args[1].u };
1015 // SAFETY: - INTERFACE requires that args[2] contains a uint
1016 let arg2 = unsafe { ZwpTabletToolV2ButtonState(args[2].u) };
1017 self.0.button(slf, arg0, arg1, arg2);
1018 }
1019 18 => {
1020 // SAFETY: INTERFACE requires that there are 1 arguments
1021 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
1022 // SAFETY: - INTERFACE requires that args[0] contains a uint
1023 let arg0 = unsafe { args[0].u };
1024 self.0.frame(slf, arg0);
1025 }
1026 _ => {
1027 invalid_opcode("zwp_tablet_tool_v2", opcode);
1028 }
1029 }
1030 }
1031}
1032
1033impl<H> CreateEventHandler<H> for private::ProxyApi
1034where
1035 H: ZwpTabletToolV2EventHandler,
1036{
1037 type EventHandler = private::EventHandler<H>;
1038
1039 #[inline]
1040 fn create_event_handler(handler: H) -> Self::EventHandler {
1041 private::EventHandler(handler)
1042 }
1043}
1044
1045impl ZwpTabletToolV2 {
1046 /// Since when the type.pen enum variant is available.
1047 #[allow(dead_code)]
1048 pub const ENM__TYPE_PEN__SINCE: u32 = 1;
1049 /// Since when the type.eraser enum variant is available.
1050 #[allow(dead_code)]
1051 pub const ENM__TYPE_ERASER__SINCE: u32 = 1;
1052 /// Since when the type.brush enum variant is available.
1053 #[allow(dead_code)]
1054 pub const ENM__TYPE_BRUSH__SINCE: u32 = 1;
1055 /// Since when the type.pencil enum variant is available.
1056 #[allow(dead_code)]
1057 pub const ENM__TYPE_PENCIL__SINCE: u32 = 1;
1058 /// Since when the type.airbrush enum variant is available.
1059 #[allow(dead_code)]
1060 pub const ENM__TYPE_AIRBRUSH__SINCE: u32 = 1;
1061 /// Since when the type.finger enum variant is available.
1062 #[allow(dead_code)]
1063 pub const ENM__TYPE_FINGER__SINCE: u32 = 1;
1064 /// Since when the type.mouse enum variant is available.
1065 #[allow(dead_code)]
1066 pub const ENM__TYPE_MOUSE__SINCE: u32 = 1;
1067 /// Since when the type.lens enum variant is available.
1068 #[allow(dead_code)]
1069 pub const ENM__TYPE_LENS__SINCE: u32 = 1;
1070
1071 /// Since when the capability.tilt enum variant is available.
1072 #[allow(dead_code)]
1073 pub const ENM__CAPABILITY_TILT__SINCE: u32 = 1;
1074 /// Since when the capability.pressure enum variant is available.
1075 #[allow(dead_code)]
1076 pub const ENM__CAPABILITY_PRESSURE__SINCE: u32 = 1;
1077 /// Since when the capability.distance enum variant is available.
1078 #[allow(dead_code)]
1079 pub const ENM__CAPABILITY_DISTANCE__SINCE: u32 = 1;
1080 /// Since when the capability.rotation enum variant is available.
1081 #[allow(dead_code)]
1082 pub const ENM__CAPABILITY_ROTATION__SINCE: u32 = 1;
1083 /// Since when the capability.slider enum variant is available.
1084 #[allow(dead_code)]
1085 pub const ENM__CAPABILITY_SLIDER__SINCE: u32 = 1;
1086 /// Since when the capability.wheel enum variant is available.
1087 #[allow(dead_code)]
1088 pub const ENM__CAPABILITY_WHEEL__SINCE: u32 = 1;
1089
1090 /// Since when the button_state.released enum variant is available.
1091 #[allow(dead_code)]
1092 pub const ENM__BUTTON_STATE_RELEASED__SINCE: u32 = 1;
1093 /// Since when the button_state.pressed enum variant is available.
1094 #[allow(dead_code)]
1095 pub const ENM__BUTTON_STATE_PRESSED__SINCE: u32 = 1;
1096
1097 /// Since when the error.role enum variant is available.
1098 #[allow(dead_code)]
1099 pub const ENM__ERROR_ROLE__SINCE: u32 = 1;
1100}
1101
1102/// a physical tool type
1103///
1104/// Describes the physical type of a tool. The physical type of a tool
1105/// generally defines its base usage.
1106///
1107/// The mouse tool represents a mouse-shaped tool that is not a relative
1108/// device but bound to the tablet's surface, providing absolute
1109/// coordinates.
1110///
1111/// The lens tool is a mouse-shaped tool with an attached lens to
1112/// provide precision focus.
1113#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1114#[allow(dead_code)]
1115pub struct ZwpTabletToolV2Type(pub u32);
1116
1117impl ZwpTabletToolV2Type {
1118 /// Pen
1119 #[allow(dead_code)]
1120 pub const PEN: Self = Self(0x140);
1121
1122 /// Eraser
1123 #[allow(dead_code)]
1124 pub const ERASER: Self = Self(0x141);
1125
1126 /// Brush
1127 #[allow(dead_code)]
1128 pub const BRUSH: Self = Self(0x142);
1129
1130 /// Pencil
1131 #[allow(dead_code)]
1132 pub const PENCIL: Self = Self(0x143);
1133
1134 /// Airbrush
1135 #[allow(dead_code)]
1136 pub const AIRBRUSH: Self = Self(0x144);
1137
1138 /// Finger
1139 #[allow(dead_code)]
1140 pub const FINGER: Self = Self(0x145);
1141
1142 /// Mouse
1143 #[allow(dead_code)]
1144 pub const MOUSE: Self = Self(0x146);
1145
1146 /// Lens
1147 #[allow(dead_code)]
1148 pub const LENS: Self = Self(0x147);
1149}
1150
1151impl Debug for ZwpTabletToolV2Type {
1152 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1153 let name = match *self {
1154 Self::PEN => "PEN",
1155 Self::ERASER => "ERASER",
1156 Self::BRUSH => "BRUSH",
1157 Self::PENCIL => "PENCIL",
1158 Self::AIRBRUSH => "AIRBRUSH",
1159 Self::FINGER => "FINGER",
1160 Self::MOUSE => "MOUSE",
1161 Self::LENS => "LENS",
1162 _ => return Debug::fmt(&self.0, f),
1163 };
1164 f.write_str(name)
1165 }
1166}
1167
1168/// capability flags for a tool
1169///
1170/// Describes extra capabilities on a tablet.
1171///
1172/// Any tool must provide x and y values, extra axes are
1173/// device-specific.
1174#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1175#[allow(dead_code)]
1176pub struct ZwpTabletToolV2Capability(pub u32);
1177
1178impl ZwpTabletToolV2Capability {
1179 /// Tilt axes
1180 #[allow(dead_code)]
1181 pub const TILT: Self = Self(1);
1182
1183 /// Pressure axis
1184 #[allow(dead_code)]
1185 pub const PRESSURE: Self = Self(2);
1186
1187 /// Distance axis
1188 #[allow(dead_code)]
1189 pub const DISTANCE: Self = Self(3);
1190
1191 /// Z-rotation axis
1192 #[allow(dead_code)]
1193 pub const ROTATION: Self = Self(4);
1194
1195 /// Slider axis
1196 #[allow(dead_code)]
1197 pub const SLIDER: Self = Self(5);
1198
1199 /// Wheel axis
1200 #[allow(dead_code)]
1201 pub const WHEEL: Self = Self(6);
1202}
1203
1204impl Debug for ZwpTabletToolV2Capability {
1205 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1206 let name = match *self {
1207 Self::TILT => "TILT",
1208 Self::PRESSURE => "PRESSURE",
1209 Self::DISTANCE => "DISTANCE",
1210 Self::ROTATION => "ROTATION",
1211 Self::SLIDER => "SLIDER",
1212 Self::WHEEL => "WHEEL",
1213 _ => return Debug::fmt(&self.0, f),
1214 };
1215 f.write_str(name)
1216 }
1217}
1218
1219/// physical button state
1220///
1221/// Describes the physical state of a button that produced the button event.
1222#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1223#[allow(dead_code)]
1224pub struct ZwpTabletToolV2ButtonState(pub u32);
1225
1226impl ZwpTabletToolV2ButtonState {
1227 /// button is not pressed
1228 #[allow(dead_code)]
1229 pub const RELEASED: Self = Self(0);
1230
1231 /// button is pressed
1232 #[allow(dead_code)]
1233 pub const PRESSED: Self = Self(1);
1234}
1235
1236impl Debug for ZwpTabletToolV2ButtonState {
1237 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1238 let name = match *self {
1239 Self::RELEASED => "RELEASED",
1240 Self::PRESSED => "PRESSED",
1241 _ => return Debug::fmt(&self.0, f),
1242 };
1243 f.write_str(name)
1244 }
1245}
1246
1247#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
1248#[allow(dead_code)]
1249pub struct ZwpTabletToolV2Error(pub u32);
1250
1251impl ZwpTabletToolV2Error {
1252 /// given wl_surface has another role
1253 #[allow(dead_code)]
1254 pub const ROLE: Self = Self(0);
1255}
1256
1257impl Debug for ZwpTabletToolV2Error {
1258 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
1259 let name = match *self {
1260 Self::ROLE => "ROLE",
1261 _ => return Debug::fmt(&self.0, f),
1262 };
1263 f.write_str(name)
1264 }
1265}
1266
1267/// Functional event handlers.
1268pub mod event_handlers {
1269 use super::*;
1270
1271 /// Event handler for type events.
1272 pub struct Type<F>(F);
1273 impl<F> ZwpTabletToolV2EventHandler for Type<F>
1274 where
1275 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Type),
1276 {
1277 #[inline]
1278 fn r#type(&self, _slf: &ZwpTabletToolV2Ref, tool_type: ZwpTabletToolV2Type) {
1279 self.0(_slf, tool_type)
1280 }
1281 }
1282
1283 /// Event handler for hardware_serial events.
1284 pub struct HardwareSerial<F>(F);
1285 impl<F> ZwpTabletToolV2EventHandler for HardwareSerial<F>
1286 where
1287 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1288 {
1289 #[inline]
1290 fn hardware_serial(
1291 &self,
1292 _slf: &ZwpTabletToolV2Ref,
1293 hardware_serial_hi: u32,
1294 hardware_serial_lo: u32,
1295 ) {
1296 self.0(_slf, hardware_serial_hi, hardware_serial_lo)
1297 }
1298 }
1299
1300 /// Event handler for hardware_id_wacom events.
1301 pub struct HardwareIdWacom<F>(F);
1302 impl<F> ZwpTabletToolV2EventHandler for HardwareIdWacom<F>
1303 where
1304 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1305 {
1306 #[inline]
1307 fn hardware_id_wacom(
1308 &self,
1309 _slf: &ZwpTabletToolV2Ref,
1310 hardware_id_hi: u32,
1311 hardware_id_lo: u32,
1312 ) {
1313 self.0(_slf, hardware_id_hi, hardware_id_lo)
1314 }
1315 }
1316
1317 /// Event handler for capability events.
1318 pub struct Capability<F>(F);
1319 impl<F> ZwpTabletToolV2EventHandler for Capability<F>
1320 where
1321 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Capability),
1322 {
1323 #[inline]
1324 fn capability(&self, _slf: &ZwpTabletToolV2Ref, capability: ZwpTabletToolV2Capability) {
1325 self.0(_slf, capability)
1326 }
1327 }
1328
1329 /// Event handler for done events.
1330 pub struct Done<F>(F);
1331 impl<F> ZwpTabletToolV2EventHandler for Done<F>
1332 where
1333 F: Fn(&ZwpTabletToolV2Ref),
1334 {
1335 #[inline]
1336 fn done(&self, _slf: &ZwpTabletToolV2Ref) {
1337 self.0(_slf)
1338 }
1339 }
1340
1341 /// Event handler for removed events.
1342 pub struct Removed<F>(F);
1343 impl<F> ZwpTabletToolV2EventHandler for Removed<F>
1344 where
1345 F: Fn(&ZwpTabletToolV2Ref),
1346 {
1347 #[inline]
1348 fn removed(&self, _slf: &ZwpTabletToolV2Ref) {
1349 self.0(_slf)
1350 }
1351 }
1352
1353 /// Event handler for proximity_in events.
1354 pub struct ProximityIn<F>(F);
1355 impl<F> ZwpTabletToolV2EventHandler for ProximityIn<F>
1356 where
1357 F: Fn(&ZwpTabletToolV2Ref, u32, Option<&ZwpTabletV2Ref>, Option<&WlSurfaceRef>),
1358 {
1359 #[inline]
1360 fn proximity_in(
1361 &self,
1362 _slf: &ZwpTabletToolV2Ref,
1363 serial: u32,
1364 tablet: Option<&ZwpTabletV2Ref>,
1365 surface: Option<&WlSurfaceRef>,
1366 ) {
1367 self.0(_slf, serial, tablet, surface)
1368 }
1369 }
1370
1371 /// Event handler for proximity_out events.
1372 pub struct ProximityOut<F>(F);
1373 impl<F> ZwpTabletToolV2EventHandler for ProximityOut<F>
1374 where
1375 F: Fn(&ZwpTabletToolV2Ref),
1376 {
1377 #[inline]
1378 fn proximity_out(&self, _slf: &ZwpTabletToolV2Ref) {
1379 self.0(_slf)
1380 }
1381 }
1382
1383 /// Event handler for down events.
1384 pub struct Down<F>(F);
1385 impl<F> ZwpTabletToolV2EventHandler for Down<F>
1386 where
1387 F: Fn(&ZwpTabletToolV2Ref, u32),
1388 {
1389 #[inline]
1390 fn down(&self, _slf: &ZwpTabletToolV2Ref, serial: u32) {
1391 self.0(_slf, serial)
1392 }
1393 }
1394
1395 /// Event handler for up events.
1396 pub struct Up<F>(F);
1397 impl<F> ZwpTabletToolV2EventHandler for Up<F>
1398 where
1399 F: Fn(&ZwpTabletToolV2Ref),
1400 {
1401 #[inline]
1402 fn up(&self, _slf: &ZwpTabletToolV2Ref) {
1403 self.0(_slf)
1404 }
1405 }
1406
1407 /// Event handler for motion events.
1408 pub struct Motion<F>(F);
1409 impl<F> ZwpTabletToolV2EventHandler for Motion<F>
1410 where
1411 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1412 {
1413 #[inline]
1414 fn motion(&self, _slf: &ZwpTabletToolV2Ref, x: Fixed, y: Fixed) {
1415 self.0(_slf, x, y)
1416 }
1417 }
1418
1419 /// Event handler for pressure events.
1420 pub struct Pressure<F>(F);
1421 impl<F> ZwpTabletToolV2EventHandler for Pressure<F>
1422 where
1423 F: Fn(&ZwpTabletToolV2Ref, u32),
1424 {
1425 #[inline]
1426 fn pressure(&self, _slf: &ZwpTabletToolV2Ref, pressure: u32) {
1427 self.0(_slf, pressure)
1428 }
1429 }
1430
1431 /// Event handler for distance events.
1432 pub struct Distance<F>(F);
1433 impl<F> ZwpTabletToolV2EventHandler for Distance<F>
1434 where
1435 F: Fn(&ZwpTabletToolV2Ref, u32),
1436 {
1437 #[inline]
1438 fn distance(&self, _slf: &ZwpTabletToolV2Ref, distance: u32) {
1439 self.0(_slf, distance)
1440 }
1441 }
1442
1443 /// Event handler for tilt events.
1444 pub struct Tilt<F>(F);
1445 impl<F> ZwpTabletToolV2EventHandler for Tilt<F>
1446 where
1447 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1448 {
1449 #[inline]
1450 fn tilt(&self, _slf: &ZwpTabletToolV2Ref, tilt_x: Fixed, tilt_y: Fixed) {
1451 self.0(_slf, tilt_x, tilt_y)
1452 }
1453 }
1454
1455 /// Event handler for rotation events.
1456 pub struct Rotation<F>(F);
1457 impl<F> ZwpTabletToolV2EventHandler for Rotation<F>
1458 where
1459 F: Fn(&ZwpTabletToolV2Ref, Fixed),
1460 {
1461 #[inline]
1462 fn rotation(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed) {
1463 self.0(_slf, degrees)
1464 }
1465 }
1466
1467 /// Event handler for slider events.
1468 pub struct Slider<F>(F);
1469 impl<F> ZwpTabletToolV2EventHandler for Slider<F>
1470 where
1471 F: Fn(&ZwpTabletToolV2Ref, i32),
1472 {
1473 #[inline]
1474 fn slider(&self, _slf: &ZwpTabletToolV2Ref, position: i32) {
1475 self.0(_slf, position)
1476 }
1477 }
1478
1479 /// Event handler for wheel events.
1480 pub struct Wheel<F>(F);
1481 impl<F> ZwpTabletToolV2EventHandler for Wheel<F>
1482 where
1483 F: Fn(&ZwpTabletToolV2Ref, Fixed, i32),
1484 {
1485 #[inline]
1486 fn wheel(&self, _slf: &ZwpTabletToolV2Ref, degrees: Fixed, clicks: i32) {
1487 self.0(_slf, degrees, clicks)
1488 }
1489 }
1490
1491 /// Event handler for button events.
1492 pub struct Button<F>(F);
1493 impl<F> ZwpTabletToolV2EventHandler for Button<F>
1494 where
1495 F: Fn(&ZwpTabletToolV2Ref, u32, u32, ZwpTabletToolV2ButtonState),
1496 {
1497 #[inline]
1498 fn button(
1499 &self,
1500 _slf: &ZwpTabletToolV2Ref,
1501 serial: u32,
1502 button: u32,
1503 state: ZwpTabletToolV2ButtonState,
1504 ) {
1505 self.0(_slf, serial, button, state)
1506 }
1507 }
1508
1509 /// Event handler for frame events.
1510 pub struct Frame<F>(F);
1511 impl<F> ZwpTabletToolV2EventHandler for Frame<F>
1512 where
1513 F: Fn(&ZwpTabletToolV2Ref, u32),
1514 {
1515 #[inline]
1516 fn frame(&self, _slf: &ZwpTabletToolV2Ref, time: u32) {
1517 self.0(_slf, time)
1518 }
1519 }
1520
1521 impl ZwpTabletToolV2 {
1522 /// Creates an event handler for type events.
1523 ///
1524 /// The event handler ignores all other events.
1525 #[allow(dead_code)]
1526 pub fn on_type<F>(f: F) -> Type<F>
1527 where
1528 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Type),
1529 {
1530 Type(f)
1531 }
1532
1533 /// Creates an event handler for hardware_serial events.
1534 ///
1535 /// The event handler ignores all other events.
1536 #[allow(dead_code)]
1537 pub fn on_hardware_serial<F>(f: F) -> HardwareSerial<F>
1538 where
1539 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1540 {
1541 HardwareSerial(f)
1542 }
1543
1544 /// Creates an event handler for hardware_id_wacom events.
1545 ///
1546 /// The event handler ignores all other events.
1547 #[allow(dead_code)]
1548 pub fn on_hardware_id_wacom<F>(f: F) -> HardwareIdWacom<F>
1549 where
1550 F: Fn(&ZwpTabletToolV2Ref, u32, u32),
1551 {
1552 HardwareIdWacom(f)
1553 }
1554
1555 /// Creates an event handler for capability events.
1556 ///
1557 /// The event handler ignores all other events.
1558 #[allow(dead_code)]
1559 pub fn on_capability<F>(f: F) -> Capability<F>
1560 where
1561 F: Fn(&ZwpTabletToolV2Ref, ZwpTabletToolV2Capability),
1562 {
1563 Capability(f)
1564 }
1565
1566 /// Creates an event handler for done events.
1567 ///
1568 /// The event handler ignores all other events.
1569 #[allow(dead_code)]
1570 pub fn on_done<F>(f: F) -> Done<F>
1571 where
1572 F: Fn(&ZwpTabletToolV2Ref),
1573 {
1574 Done(f)
1575 }
1576
1577 /// Creates an event handler for removed events.
1578 ///
1579 /// The event handler ignores all other events.
1580 #[allow(dead_code)]
1581 pub fn on_removed<F>(f: F) -> Removed<F>
1582 where
1583 F: Fn(&ZwpTabletToolV2Ref),
1584 {
1585 Removed(f)
1586 }
1587
1588 /// Creates an event handler for proximity_in events.
1589 ///
1590 /// The event handler ignores all other events.
1591 #[allow(dead_code)]
1592 pub fn on_proximity_in<F>(f: F) -> ProximityIn<F>
1593 where
1594 F: Fn(&ZwpTabletToolV2Ref, u32, Option<&ZwpTabletV2Ref>, Option<&WlSurfaceRef>),
1595 {
1596 ProximityIn(f)
1597 }
1598
1599 /// Creates an event handler for proximity_out events.
1600 ///
1601 /// The event handler ignores all other events.
1602 #[allow(dead_code)]
1603 pub fn on_proximity_out<F>(f: F) -> ProximityOut<F>
1604 where
1605 F: Fn(&ZwpTabletToolV2Ref),
1606 {
1607 ProximityOut(f)
1608 }
1609
1610 /// Creates an event handler for down events.
1611 ///
1612 /// The event handler ignores all other events.
1613 #[allow(dead_code)]
1614 pub fn on_down<F>(f: F) -> Down<F>
1615 where
1616 F: Fn(&ZwpTabletToolV2Ref, u32),
1617 {
1618 Down(f)
1619 }
1620
1621 /// Creates an event handler for up events.
1622 ///
1623 /// The event handler ignores all other events.
1624 #[allow(dead_code)]
1625 pub fn on_up<F>(f: F) -> Up<F>
1626 where
1627 F: Fn(&ZwpTabletToolV2Ref),
1628 {
1629 Up(f)
1630 }
1631
1632 /// Creates an event handler for motion events.
1633 ///
1634 /// The event handler ignores all other events.
1635 #[allow(dead_code)]
1636 pub fn on_motion<F>(f: F) -> Motion<F>
1637 where
1638 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1639 {
1640 Motion(f)
1641 }
1642
1643 /// Creates an event handler for pressure events.
1644 ///
1645 /// The event handler ignores all other events.
1646 #[allow(dead_code)]
1647 pub fn on_pressure<F>(f: F) -> Pressure<F>
1648 where
1649 F: Fn(&ZwpTabletToolV2Ref, u32),
1650 {
1651 Pressure(f)
1652 }
1653
1654 /// Creates an event handler for distance events.
1655 ///
1656 /// The event handler ignores all other events.
1657 #[allow(dead_code)]
1658 pub fn on_distance<F>(f: F) -> Distance<F>
1659 where
1660 F: Fn(&ZwpTabletToolV2Ref, u32),
1661 {
1662 Distance(f)
1663 }
1664
1665 /// Creates an event handler for tilt events.
1666 ///
1667 /// The event handler ignores all other events.
1668 #[allow(dead_code)]
1669 pub fn on_tilt<F>(f: F) -> Tilt<F>
1670 where
1671 F: Fn(&ZwpTabletToolV2Ref, Fixed, Fixed),
1672 {
1673 Tilt(f)
1674 }
1675
1676 /// Creates an event handler for rotation events.
1677 ///
1678 /// The event handler ignores all other events.
1679 #[allow(dead_code)]
1680 pub fn on_rotation<F>(f: F) -> Rotation<F>
1681 where
1682 F: Fn(&ZwpTabletToolV2Ref, Fixed),
1683 {
1684 Rotation(f)
1685 }
1686
1687 /// Creates an event handler for slider events.
1688 ///
1689 /// The event handler ignores all other events.
1690 #[allow(dead_code)]
1691 pub fn on_slider<F>(f: F) -> Slider<F>
1692 where
1693 F: Fn(&ZwpTabletToolV2Ref, i32),
1694 {
1695 Slider(f)
1696 }
1697
1698 /// Creates an event handler for wheel events.
1699 ///
1700 /// The event handler ignores all other events.
1701 #[allow(dead_code)]
1702 pub fn on_wheel<F>(f: F) -> Wheel<F>
1703 where
1704 F: Fn(&ZwpTabletToolV2Ref, Fixed, i32),
1705 {
1706 Wheel(f)
1707 }
1708
1709 /// Creates an event handler for button events.
1710 ///
1711 /// The event handler ignores all other events.
1712 #[allow(dead_code)]
1713 pub fn on_button<F>(f: F) -> Button<F>
1714 where
1715 F: Fn(&ZwpTabletToolV2Ref, u32, u32, ZwpTabletToolV2ButtonState),
1716 {
1717 Button(f)
1718 }
1719
1720 /// Creates an event handler for frame events.
1721 ///
1722 /// The event handler ignores all other events.
1723 #[allow(dead_code)]
1724 pub fn on_frame<F>(f: F) -> Frame<F>
1725 where
1726 F: Fn(&ZwpTabletToolV2Ref, u32),
1727 {
1728 Frame(f)
1729 }
1730 }
1731}