1 | // This file contains generated code. Do not edit directly. |
2 | // To regenerate this, run 'make'. |
3 | |
4 | //! Bindings to the `Shape` X11 extension. |
5 | |
6 | #![allow (clippy::too_many_arguments)] |
7 | |
8 | #[allow (unused_imports)] |
9 | use std::borrow::Cow; |
10 | #[allow (unused_imports)] |
11 | use std::convert::TryInto; |
12 | #[allow (unused_imports)] |
13 | use crate::utils::RawFdContainer; |
14 | #[allow (unused_imports)] |
15 | use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; |
16 | use std::io::IoSlice; |
17 | use crate::connection::RequestConnection; |
18 | #[allow (unused_imports)] |
19 | use crate::connection::Connection as X11Connection; |
20 | #[allow (unused_imports)] |
21 | use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; |
22 | use crate::errors::ConnectionError; |
23 | #[allow (unused_imports)] |
24 | use crate::errors::ReplyOrIdError; |
25 | #[allow (unused_imports)] |
26 | use super::xproto; |
27 | |
28 | pub use x11rb_protocol::protocol::shape::*; |
29 | |
30 | /// Get the major opcode of this extension |
31 | fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> { |
32 | let info: Option = conn.extension_information(X11_EXTENSION_NAME)?; |
33 | let info: ExtensionInformation = info.ok_or(err:ConnectionError::UnsupportedExtension)?; |
34 | Ok(info.major_opcode) |
35 | } |
36 | |
37 | pub fn query_version<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> |
38 | where |
39 | Conn: RequestConnection + ?Sized, |
40 | { |
41 | let request0: QueryVersionRequest = QueryVersionRequest; |
42 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
43 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
44 | assert_eq!(slices.len(), bytes.len()); |
45 | conn.send_request_with_reply(&slices, fds) |
46 | } |
47 | |
48 | pub fn rectangles<'c, 'input, Conn>(conn: &'c Conn, operation: SO, destination_kind: SK, ordering: xproto::ClipOrdering, destination_window: xproto::Window, x_offset: i16, y_offset: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError> |
49 | where |
50 | Conn: RequestConnection + ?Sized, |
51 | { |
52 | let request0: RectanglesRequest<'_> = RectanglesRequest { |
53 | operation, |
54 | destination_kind, |
55 | ordering, |
56 | destination_window, |
57 | x_offset, |
58 | y_offset, |
59 | rectangles: Cow::Borrowed(rectangles), |
60 | }; |
61 | let (bytes: [Cow<'_, [u8]>; 3], fds: Vec) = request0.serialize(major_opcode(conn)?); |
62 | let slices: [IoSlice<'_>; 3] = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])]; |
63 | assert_eq!(slices.len(), bytes.len()); |
64 | conn.send_request_without_reply(&slices, fds) |
65 | } |
66 | |
67 | pub fn mask<Conn, A>(conn: &Conn, operation: SO, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_bitmap: A) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
68 | where |
69 | Conn: RequestConnection + ?Sized, |
70 | A: Into<xproto::Pixmap>, |
71 | { |
72 | let source_bitmap: xproto::Pixmap = source_bitmap.into(); |
73 | let request0: MaskRequest = MaskRequest { |
74 | operation, |
75 | destination_kind, |
76 | destination_window, |
77 | x_offset, |
78 | y_offset, |
79 | source_bitmap, |
80 | }; |
81 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
82 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
83 | assert_eq!(slices.len(), bytes.len()); |
84 | conn.send_request_without_reply(&slices, fds) |
85 | } |
86 | |
87 | pub fn combine<Conn>(conn: &Conn, operation: SO, destination_kind: SK, source_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
88 | where |
89 | Conn: RequestConnection + ?Sized, |
90 | { |
91 | let request0: CombineRequest = CombineRequest { |
92 | operation, |
93 | destination_kind, |
94 | source_kind, |
95 | destination_window, |
96 | x_offset, |
97 | y_offset, |
98 | source_window, |
99 | }; |
100 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
101 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
102 | assert_eq!(slices.len(), bytes.len()); |
103 | conn.send_request_without_reply(&slices, fds) |
104 | } |
105 | |
106 | pub fn offset<Conn>(conn: &Conn, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
107 | where |
108 | Conn: RequestConnection + ?Sized, |
109 | { |
110 | let request0: OffsetRequest = OffsetRequest { |
111 | destination_kind, |
112 | destination_window, |
113 | x_offset, |
114 | y_offset, |
115 | }; |
116 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
117 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
118 | assert_eq!(slices.len(), bytes.len()); |
119 | conn.send_request_without_reply(&slices, fds) |
120 | } |
121 | |
122 | pub fn query_extents<Conn>(conn: &Conn, destination_window: xproto::Window) -> Result<Cookie<'_, Conn, QueryExtentsReply>, ConnectionError> |
123 | where |
124 | Conn: RequestConnection + ?Sized, |
125 | { |
126 | let request0: QueryExtentsRequest = QueryExtentsRequest { |
127 | destination_window, |
128 | }; |
129 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
130 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
131 | assert_eq!(slices.len(), bytes.len()); |
132 | conn.send_request_with_reply(&slices, fds) |
133 | } |
134 | |
135 | pub fn select_input<Conn>(conn: &Conn, destination_window: xproto::Window, enable: bool) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
136 | where |
137 | Conn: RequestConnection + ?Sized, |
138 | { |
139 | let request0: SelectInputRequest = SelectInputRequest { |
140 | destination_window, |
141 | enable, |
142 | }; |
143 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
144 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
145 | assert_eq!(slices.len(), bytes.len()); |
146 | conn.send_request_without_reply(&slices, fds) |
147 | } |
148 | |
149 | pub fn input_selected<Conn>(conn: &Conn, destination_window: xproto::Window) -> Result<Cookie<'_, Conn, InputSelectedReply>, ConnectionError> |
150 | where |
151 | Conn: RequestConnection + ?Sized, |
152 | { |
153 | let request0: InputSelectedRequest = InputSelectedRequest { |
154 | destination_window, |
155 | }; |
156 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
157 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
158 | assert_eq!(slices.len(), bytes.len()); |
159 | conn.send_request_with_reply(&slices, fds) |
160 | } |
161 | |
162 | pub fn get_rectangles<Conn>(conn: &Conn, window: xproto::Window, source_kind: SK) -> Result<Cookie<'_, Conn, GetRectanglesReply>, ConnectionError> |
163 | where |
164 | Conn: RequestConnection + ?Sized, |
165 | { |
166 | let request0: GetRectanglesRequest = GetRectanglesRequest { |
167 | window, |
168 | source_kind, |
169 | }; |
170 | let (bytes: [Cow<'static, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode(conn)?); |
171 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
172 | assert_eq!(slices.len(), bytes.len()); |
173 | conn.send_request_with_reply(&slices, fds) |
174 | } |
175 | |
176 | /// Extension trait defining the requests of this extension. |
177 | pub trait ConnectionExt: RequestConnection { |
178 | fn shape_query_version(&self) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError> |
179 | { |
180 | query_version(self) |
181 | } |
182 | fn shape_rectangles<'c, 'input>(&'c self, operation: SO, destination_kind: SK, ordering: xproto::ClipOrdering, destination_window: xproto::Window, x_offset: i16, y_offset: i16, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError> |
183 | { |
184 | self::rectangles(self, operation, destination_kind, ordering, destination_window, x_offset, y_offset, rectangles) |
185 | } |
186 | fn shape_mask<A>(&self, operation: SO, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_bitmap: A) -> Result<VoidCookie<'_, Self>, ConnectionError> |
187 | where |
188 | A: Into<xproto::Pixmap>, |
189 | { |
190 | mask(self, operation, destination_kind, destination_window, x_offset, y_offset, source_bitmap) |
191 | } |
192 | fn shape_combine(&self, operation: SO, destination_kind: SK, source_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16, source_window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError> |
193 | { |
194 | combine(self, operation, destination_kind, source_kind, destination_window, x_offset, y_offset, source_window) |
195 | } |
196 | fn shape_offset(&self, destination_kind: SK, destination_window: xproto::Window, x_offset: i16, y_offset: i16) -> Result<VoidCookie<'_, Self>, ConnectionError> |
197 | { |
198 | offset(self, destination_kind, destination_window, x_offset, y_offset) |
199 | } |
200 | fn shape_query_extents(&self, destination_window: xproto::Window) -> Result<Cookie<'_, Self, QueryExtentsReply>, ConnectionError> |
201 | { |
202 | query_extents(self, destination_window) |
203 | } |
204 | fn shape_select_input(&self, destination_window: xproto::Window, enable: bool) -> Result<VoidCookie<'_, Self>, ConnectionError> |
205 | { |
206 | select_input(self, destination_window, enable) |
207 | } |
208 | fn shape_input_selected(&self, destination_window: xproto::Window) -> Result<Cookie<'_, Self, InputSelectedReply>, ConnectionError> |
209 | { |
210 | input_selected(self, destination_window) |
211 | } |
212 | fn shape_get_rectangles(&self, window: xproto::Window, source_kind: SK) -> Result<Cookie<'_, Self, GetRectanglesReply>, ConnectionError> |
213 | { |
214 | get_rectangles(self, window, source_kind) |
215 | } |
216 | } |
217 | |
218 | impl<C: RequestConnection + ?Sized> ConnectionExt for C {} |
219 | |