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