simple_window/common/protocols_data/wayland/
wl_fixes.rs

1//! wayland protocol fixes
2//!
3//! This global fixes problems with other core-protocol interfaces that
4//! cannot be fixed in these interfaces themselves.
5
6use {super::super::all_types::*, ::wl_client::builder::prelude::*};
7
8static INTERFACE: wl_interface = wl_interface {
9    name: c"wl_fixes".as_ptr(),
10    version: 1,
11    method_count: 2,
12    methods: {
13        static MESSAGES: [wl_message; 2] = [
14            wl_message {
15                name: c"destroy".as_ptr(),
16                signature: c"".as_ptr(),
17                types: {
18                    static TYPES: [Option<&'static wl_interface>; 0] = [];
19                    TYPES.as_ptr().cast()
20                },
21            },
22            wl_message {
23                name: c"destroy_registry".as_ptr(),
24                signature: c"o".as_ptr(),
25                types: {
26                    static TYPES: [Option<&'static wl_interface>; 1] =
27                        [Some(WlRegistry::WL_INTERFACE)];
28                    TYPES.as_ptr().cast()
29                },
30            },
31        ];
32        MESSAGES.as_ptr()
33    },
34    event_count: 0,
35    events: ptr::null(),
36};
37
38/// An owned wl_fixes proxy.
39///
40/// See the documentation of [the module][self] for the interface description.
41#[derive(Clone, Eq, PartialEq)]
42#[repr(transparent)]
43pub struct WlFixes {
44    /// This proxy has the interface INTERFACE.
45    proxy: UntypedOwnedProxy,
46}
47
48/// A borrowed wl_fixes proxy.
49///
50/// See the documentation of [the module][self] for the interface description.
51#[derive(Eq, PartialEq)]
52#[repr(transparent)]
53pub struct WlFixesRef {
54    /// This proxy has the interface INTERFACE.
55    proxy: UntypedBorrowedProxy,
56}
57
58// SAFETY: WlFixes is a transparent wrapper around UntypedOwnedProxy
59unsafe impl UntypedOwnedProxyWrapper for WlFixes {}
60
61// SAFETY: - INTERFACE is a valid wl_interface
62//         - The only invariant is that self.proxy has a compatible interface
63unsafe impl OwnedProxy for WlFixes {
64    const INTERFACE: &'static str = "wl_fixes";
65    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
66    const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
67        private::EventHandler(private::NoOpEventHandler);
68    const MAX_VERSION: u32 = 1;
69
70    type Borrowed = WlFixesRef;
71    type Api = private::ProxyApi;
72    type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
73}
74
75// SAFETY: WlFixesRef is a transparent wrapper around UntypedBorrowedProxy
76unsafe impl UntypedBorrowedProxyWrapper for WlFixesRef {}
77
78// SAFETY: - The only invariant is that self.proxy has a compatible interface
79unsafe impl BorrowedProxy for WlFixesRef {
80    type Owned = WlFixes;
81}
82
83impl Deref for WlFixes {
84    type Target = WlFixesRef;
85
86    fn deref(&self) -> &Self::Target {
87        proxy::low_level::deref(self)
88    }
89}
90
91mod private {
92    pub struct ProxyApi;
93
94    #[allow(dead_code)]
95    pub struct EventHandler<H>(pub(super) H);
96
97    #[allow(dead_code)]
98    pub struct NoOpEventHandler;
99}
100
101impl Debug for WlFixes {
102    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
103        write!(f, "wl_fixes#{}", self.proxy.id())
104    }
105}
106
107impl Debug for WlFixesRef {
108    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
109        write!(f, "wl_fixes#{}", self.proxy.id())
110    }
111}
112
113impl PartialEq<WlFixesRef> for WlFixes {
114    fn eq(&self, other: &WlFixesRef) -> bool {
115        self.proxy == other.proxy
116    }
117}
118
119impl PartialEq<WlFixes> for WlFixesRef {
120    fn eq(&self, other: &WlFixes) -> bool {
121        self.proxy == other.proxy
122    }
123}
124
125#[allow(dead_code)]
126impl WlFixes {
127    /// Since when the destroy request is available.
128    #[allow(dead_code)]
129    pub const REQ__DESTROY__SINCE: u32 = 1;
130
131    /// destroys this object
132    #[inline]
133    pub fn destroy(&self) {
134        let mut args = [];
135        // SAFETY: - self.proxy has the interface INTERFACE
136        //         - 0 < INTERFACE.method_count = 2
137        //         - the request signature is ``
138        unsafe {
139            self.proxy.send_destructor(0, &mut args);
140        }
141    }
142}
143
144#[allow(dead_code)]
145impl WlFixesRef {
146    /// destroy a wl_registry
147    ///
148    /// This request destroys a wl_registry object.
149    ///
150    /// The client should no longer use the wl_registry after making this
151    /// request.
152    ///
153    /// The compositor will emit a wl_display.delete_id event with the object ID
154    /// of the registry and will no longer emit any events on the registry. The
155    /// client should re-use the object ID once it receives the
156    /// wl_display.delete_id event.
157    ///
158    /// # Arguments
159    ///
160    /// - `registry`: the registry to destroy
161    #[inline]
162    pub fn destroy_registry(&self, registry: &WlRegistryRef) {
163        let (arg0,) = (registry,);
164        let obj0_lock = proxy::lock(arg0);
165        let obj0 = check_argument_proxy("registry", obj0_lock.wl_proxy());
166        let mut args = [wl_argument { o: obj0 }];
167        // SAFETY: - self.proxy has the interface INTERFACE
168        //         - 1 < INTERFACE.method_count = 2
169        //         - the request signature is `o`
170        unsafe {
171            self.proxy.send_request(1, &mut args);
172        }
173    }
174}
175
176/// An event handler for [WlFixes] proxies.
177#[allow(dead_code)]
178pub trait WlFixesEventHandler {
179    type Data: 'static;
180}
181
182impl WlFixesEventHandler for private::NoOpEventHandler {
183    type Data = ();
184}
185
186// SAFETY: - INTERFACE is a valid wl_interface
187//         - mutable_type always returns the same value
188unsafe impl<H> EventHandler for private::EventHandler<H>
189where
190    H: WlFixesEventHandler,
191{
192    const WL_INTERFACE: &'static wl_interface = &INTERFACE;
193
194    #[inline]
195    fn mutable_type() -> Option<(TypeId, &'static str)> {
196        let id = TypeId::of::<H::Data>();
197        let name = std::any::type_name::<H::Data>();
198        Some((id, name))
199    }
200
201    #[allow(unused_variables)]
202    unsafe fn handle_event(
203        &self,
204        queue: &Queue,
205        data: *mut u8,
206        slf: &UntypedBorrowedProxy,
207        opcode: u32,
208        args: *mut wl_argument,
209    ) {
210        invalid_opcode("wl_fixes", opcode);
211    }
212}
213
214impl<H> CreateEventHandler<H> for private::ProxyApi
215where
216    H: WlFixesEventHandler,
217{
218    type EventHandler = private::EventHandler<H>;
219
220    #[inline]
221    fn create_event_handler(handler: H) -> Self::EventHandler {
222        private::EventHandler(handler)
223    }
224}
225
226/// Functional event handlers.
227pub mod event_handlers {
228    use super::*;
229
230    impl WlFixes {}
231}