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