Skip to main content

get_registry/common/protocols_data/tablet_v2/
zwp_tablet_manager_v2.rs

1//! controller object for graphic tablet devices
2//!
3//! An object that provides access to the graphics tablets available on this
4//! system. All tablets are associated with a seat, to get access to the
5//! actual tablets, use wp_tablet_manager.get_tablet_seat.
6
7use super::super::all_types::*;
8use ::wl_client::builder::prelude::*;
9
10static INTERFACE: wl_interface = wl_interface {
11    name: c"zwp_tablet_manager_v2".as_ptr(),
12    version: 1,
13    method_count: 2,
14    methods: {
15        static MESSAGES: [wl_message; 2] = [
16            wl_message {
17                name: c"get_tablet_seat".as_ptr(),
18                signature: c"no".as_ptr(),
19                types: {
20                    static TYPES: [Option<&'static wl_interface>; 2] = [
21                        Some(ZwpTabletSeatV2::WL_INTERFACE),
22                        Some(WlSeat::WL_INTERFACE),
23                    ];
24                    TYPES.as_ptr().cast()
25                },
26            },
27            wl_message {
28                name: c"destroy".as_ptr(),
29                signature: c"".as_ptr(),
30                types: {
31                    static TYPES: [Option<&'static wl_interface>; 0] = [];
32                    TYPES.as_ptr().cast()
33                },
34            },
35        ];
36        MESSAGES.as_ptr()
37    },
38    event_count: 0,
39    events: ptr::null(),
40};
41
42/// An owned zwp_tablet_manager_v2 proxy.
43///
44/// See the documentation of [the module][self] for the interface description.
45#[derive(Clone, Eq, PartialEq)]
46#[repr(transparent)]
47pub struct ZwpTabletManagerV2 {
48    /// This proxy has the interface INTERFACE.
49    proxy: UntypedOwnedProxy,
50}
51
52/// A borrowed zwp_tablet_manager_v2 proxy.
53///
54/// See the documentation of [the module][self] for the interface description.
55#[derive(Eq, PartialEq)]
56#[repr(transparent)]
57pub struct ZwpTabletManagerV2Ref {
58    /// This proxy has the interface INTERFACE.
59    proxy: UntypedBorrowedProxy,
60}
61
62// SAFETY: ZwpTabletManagerV2 is a transparent wrapper around UntypedOwnedProxy
63unsafe impl UntypedOwnedProxyWrapper for ZwpTabletManagerV2 {}
64
65// SAFETY: - INTERFACE is a valid wl_interface
66//         - The only invariant is that self.proxy has a compatible interface
67unsafe impl OwnedProxy for ZwpTabletManagerV2 {
68    const INTERFACE: &'static str = "zwp_tablet_manager_v2";
69    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
70    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
71        private::EventHandler(private::NoOpEventHandler);
72    const MAX_VERSION: u32 = 1;
73
74    type Borrowed = ZwpTabletManagerV2Ref;
75    type Api = private::ProxyApi;
76    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
77}
78
79// SAFETY: ZwpTabletManagerV2Ref is a transparent wrapper around UntypedBorrowedProxy
80unsafe impl UntypedBorrowedProxyWrapper for ZwpTabletManagerV2Ref {}
81
82// SAFETY: - The only invariant is that self.proxy has a compatible interface
83unsafe impl BorrowedProxy for ZwpTabletManagerV2Ref {
84    type Owned = ZwpTabletManagerV2;
85}
86
87impl Deref for ZwpTabletManagerV2 {
88    type Target = ZwpTabletManagerV2Ref;
89
90    fn deref(&self) -> &Self::Target {
91        proxy::low_level::deref(self)
92    }
93}
94
95mod private {
96    pub struct ProxyApi;
97
98    #[allow(dead_code)]
99    pub struct EventHandler<H>(pub(super) H);
100
101    #[allow(dead_code)]
102    pub struct NoOpEventHandler;
103}
104
105impl Debug for ZwpTabletManagerV2 {
106    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
107        write!(f, "zwp_tablet_manager_v2#{}", self.proxy.id())
108    }
109}
110
111impl Debug for ZwpTabletManagerV2Ref {
112    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
113        write!(f, "zwp_tablet_manager_v2#{}", self.proxy.id())
114    }
115}
116
117impl PartialEq<ZwpTabletManagerV2Ref> for ZwpTabletManagerV2 {
118    fn eq(&self, other: &ZwpTabletManagerV2Ref) -> bool {
119        self.proxy == other.proxy
120    }
121}
122
123impl PartialEq<ZwpTabletManagerV2> for ZwpTabletManagerV2Ref {
124    fn eq(&self, other: &ZwpTabletManagerV2) -> bool {
125        self.proxy == other.proxy
126    }
127}
128
129#[allow(dead_code)]
130impl ZwpTabletManagerV2 {
131    /// Since when the get_tablet_seat request is available.
132    #[allow(dead_code)]
133    pub const REQ__GET_TABLET_SEAT__SINCE: u32 = 1;
134
135    /// Since when the destroy request is available.
136    #[allow(dead_code)]
137    pub const REQ__DESTROY__SINCE: u32 = 1;
138}
139
140#[allow(dead_code)]
141impl ZwpTabletManagerV2 {
142    /// get the tablet seat
143    ///
144    /// Get the wp_tablet_seat object for the given seat. This object
145    /// provides access to all graphics tablets in this seat.
146    ///
147    /// # Arguments
148    ///
149    /// - `seat`: The wl_seat object to retrieve the tablets for
150    #[inline]
151    pub fn get_tablet_seat(&self, seat: &WlSeatRef) -> ZwpTabletSeatV2 {
152        let (arg1,) = (seat,);
153        let obj1_lock = proxy::lock(arg1);
154        let obj1 = check_argument_proxy("seat", obj1_lock.wl_proxy());
155        let mut args = [wl_argument { n: 0 }, wl_argument { o: obj1 }];
156        // SAFETY: - self.proxy has the interface INTERFACE
157        //         - 0 < INTERFACE.method_count = 2
158        //         - the request signature is `no`
159        //         - OwnedProxy::WL_INTERFACE is always a valid interface
160        let data = unsafe {
161            self.proxy
162                .send_constructor::<false>(0, &mut args, ZwpTabletSeatV2::WL_INTERFACE, None)
163        };
164        // SAFETY: data has the interface ZwpTabletSeatV2::WL_INTERFACE
165        unsafe { proxy::low_level::from_untyped_owned(data) }
166    }
167
168    /// release the memory for the tablet manager object
169    ///
170    /// Destroy the wp_tablet_manager object. Objects created from this
171    /// object are unaffected and should be destroyed separately.
172    #[inline]
173    pub fn destroy(&self) {
174        let mut args = [];
175        // SAFETY: - self.proxy has the interface INTERFACE
176        //         - 1 < INTERFACE.method_count = 2
177        //         - the request signature is ``
178        unsafe {
179            self.proxy.send_destructor(1, &mut args);
180        }
181    }
182}
183
184#[allow(dead_code)]
185impl ZwpTabletManagerV2Ref {
186    /// get the tablet seat
187    ///
188    /// Get the wp_tablet_seat object for the given seat. This object
189    /// provides access to all graphics tablets in this seat.
190    ///
191    /// # Arguments
192    ///
193    /// - `_queue`: The queue that the returned proxy is assigned to.
194    /// - `seat`: The wl_seat object to retrieve the tablets for
195    #[inline]
196    pub fn get_tablet_seat(&self, _queue: &Queue, seat: &WlSeatRef) -> ZwpTabletSeatV2 {
197        let (arg1,) = (seat,);
198        let obj1_lock = proxy::lock(arg1);
199        let obj1 = check_argument_proxy("seat", obj1_lock.wl_proxy());
200        let mut args = [wl_argument { n: 0 }, wl_argument { o: obj1 }];
201        // SAFETY: - self.proxy has the interface INTERFACE
202        //         - 0 < INTERFACE.method_count = 2
203        //         - the request signature is `no`
204        //         - OwnedProxy::WL_INTERFACE is always a valid interface
205        let data = unsafe {
206            self.proxy
207                .send_constructor(_queue, 0, &mut args, ZwpTabletSeatV2::WL_INTERFACE, None)
208        };
209        // SAFETY: data has the interface ZwpTabletSeatV2::WL_INTERFACE
210        unsafe { proxy::low_level::from_untyped_owned(data) }
211    }
212}
213
214/// An event handler for [ZwpTabletManagerV2] proxies.
215#[allow(dead_code)]
216pub trait ZwpTabletManagerV2EventHandler {
217    type Data: 'static;
218}
219
220impl ZwpTabletManagerV2EventHandler for private::NoOpEventHandler {
221    type Data = ();
222}
223
224// SAFETY: - INTERFACE is a valid wl_interface
225//         - mutable_type always returns the same value
226unsafe impl<H> EventHandler for private::EventHandler<H>
227where
228    H: ZwpTabletManagerV2EventHandler,
229{
230    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
231
232    #[inline]
233    fn mutable_type() -> Option<(TypeId, &'static str)> {
234        let id = TypeId::of::<H::Data>();
235        let name = std::any::type_name::<H::Data>();
236        Some((id, name))
237    }
238
239    #[allow(unused_variables)]
240    unsafe fn handle_event(
241        &self,
242        queue: &Queue,
243        data: *mut u8,
244        slf: &UntypedBorrowedProxy,
245        opcode: u32,
246        args: *mut wl_argument,
247    ) {
248        invalid_opcode("zwp_tablet_manager_v2", opcode);
249    }
250}
251
252impl<H> CreateEventHandler<H> for private::ProxyApi
253where
254    H: ZwpTabletManagerV2EventHandler,
255{
256    type EventHandler = private::EventHandler<H>;
257
258    #[inline]
259    fn create_event_handler(handler: H) -> Self::EventHandler {
260        private::EventHandler(handler)
261    }
262}
263
264/// Functional event handlers.
265pub mod event_handlers {
266    use super::*;
267
268    impl ZwpTabletManagerV2 {}
269}