1 | // This file contains generated code. Do not edit directly. |
2 | // To regenerate this, run 'make'. |
3 | |
4 | //! Bindings to the `XFixes` 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::render; |
27 | #[allow (unused_imports)] |
28 | use super::shape; |
29 | #[allow (unused_imports)] |
30 | use super::xproto; |
31 | |
32 | pub use x11rb_protocol::protocol::xfixes::*; |
33 | |
34 | /// Get the major opcode of this extension |
35 | fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> { |
36 | let info: Option = conn.extension_information(X11_EXTENSION_NAME)?; |
37 | let info: ExtensionInformation = info.ok_or(err:ConnectionError::UnsupportedExtension)?; |
38 | Ok(info.major_opcode) |
39 | } |
40 | |
41 | pub fn query_version<Conn>(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError> |
42 | where |
43 | Conn: RequestConnection + ?Sized, |
44 | { |
45 | let request0: QueryVersionRequest = QueryVersionRequest { |
46 | client_major_version, |
47 | client_minor_version, |
48 | }; |
49 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
50 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
51 | assert_eq!(slices.len(), bytes.len()); |
52 | conn.send_request_with_reply(&slices, fds) |
53 | } |
54 | |
55 | pub fn change_save_set<Conn>(conn: &Conn, mode: SaveSetMode, target: SaveSetTarget, map: SaveSetMapping, window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
56 | where |
57 | Conn: RequestConnection + ?Sized, |
58 | { |
59 | let request0: ChangeSaveSetRequest = ChangeSaveSetRequest { |
60 | mode, |
61 | target, |
62 | map, |
63 | window, |
64 | }; |
65 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
66 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
67 | assert_eq!(slices.len(), bytes.len()); |
68 | conn.send_request_without_reply(&slices, fds) |
69 | } |
70 | |
71 | pub fn select_selection_input<Conn>(conn: &Conn, window: xproto::Window, selection: xproto::Atom, event_mask: SelectionEventMask) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
72 | where |
73 | Conn: RequestConnection + ?Sized, |
74 | { |
75 | let request0: SelectSelectionInputRequest = SelectSelectionInputRequest { |
76 | window, |
77 | selection, |
78 | event_mask, |
79 | }; |
80 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
81 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
82 | assert_eq!(slices.len(), bytes.len()); |
83 | conn.send_request_without_reply(&slices, fds) |
84 | } |
85 | |
86 | pub fn select_cursor_input<Conn>(conn: &Conn, window: xproto::Window, event_mask: CursorNotifyMask) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
87 | where |
88 | Conn: RequestConnection + ?Sized, |
89 | { |
90 | let request0: SelectCursorInputRequest = SelectCursorInputRequest { |
91 | window, |
92 | event_mask, |
93 | }; |
94 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
95 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
96 | assert_eq!(slices.len(), bytes.len()); |
97 | conn.send_request_without_reply(&slices, fds) |
98 | } |
99 | |
100 | pub fn get_cursor_image<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetCursorImageReply>, ConnectionError> |
101 | where |
102 | Conn: RequestConnection + ?Sized, |
103 | { |
104 | let request0: GetCursorImageRequest = GetCursorImageRequest; |
105 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
106 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
107 | assert_eq!(slices.len(), bytes.len()); |
108 | conn.send_request_with_reply(&slices, fds) |
109 | } |
110 | |
111 | pub fn create_region<'c, 'input, Conn>(conn: &'c Conn, region: Region, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError> |
112 | where |
113 | Conn: RequestConnection + ?Sized, |
114 | { |
115 | let request0: CreateRegionRequest<'_> = CreateRegionRequest { |
116 | region, |
117 | rectangles: Cow::Borrowed(rectangles), |
118 | }; |
119 | let (bytes: [Cow<'_, [u8]>; 3], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
120 | let slices: [IoSlice<'_>; 3] = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])]; |
121 | assert_eq!(slices.len(), bytes.len()); |
122 | conn.send_request_without_reply(&slices, fds) |
123 | } |
124 | |
125 | pub fn create_region_from_bitmap<Conn>(conn: &Conn, region: Region, bitmap: xproto::Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
126 | where |
127 | Conn: RequestConnection + ?Sized, |
128 | { |
129 | let request0: CreateRegionFromBitmapRequest = CreateRegionFromBitmapRequest { |
130 | region, |
131 | bitmap, |
132 | }; |
133 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
134 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
135 | assert_eq!(slices.len(), bytes.len()); |
136 | conn.send_request_without_reply(&slices, fds) |
137 | } |
138 | |
139 | pub fn create_region_from_window<Conn>(conn: &Conn, region: Region, window: xproto::Window, kind: shape::SK) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
140 | where |
141 | Conn: RequestConnection + ?Sized, |
142 | { |
143 | let request0: CreateRegionFromWindowRequest = CreateRegionFromWindowRequest { |
144 | region, |
145 | window, |
146 | kind, |
147 | }; |
148 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
149 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
150 | assert_eq!(slices.len(), bytes.len()); |
151 | conn.send_request_without_reply(&slices, fds) |
152 | } |
153 | |
154 | pub fn create_region_from_gc<Conn>(conn: &Conn, region: Region, gc: xproto::Gcontext) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
155 | where |
156 | Conn: RequestConnection + ?Sized, |
157 | { |
158 | let request0: CreateRegionFromGCRequest = CreateRegionFromGCRequest { |
159 | region, |
160 | gc, |
161 | }; |
162 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
163 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
164 | assert_eq!(slices.len(), bytes.len()); |
165 | conn.send_request_without_reply(&slices, fds) |
166 | } |
167 | |
168 | pub fn create_region_from_picture<Conn>(conn: &Conn, region: Region, picture: render::Picture) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
169 | where |
170 | Conn: RequestConnection + ?Sized, |
171 | { |
172 | let request0: CreateRegionFromPictureRequest = CreateRegionFromPictureRequest { |
173 | region, |
174 | picture, |
175 | }; |
176 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
177 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
178 | assert_eq!(slices.len(), bytes.len()); |
179 | conn.send_request_without_reply(&slices, fds) |
180 | } |
181 | |
182 | pub fn destroy_region<Conn>(conn: &Conn, region: Region) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
183 | where |
184 | Conn: RequestConnection + ?Sized, |
185 | { |
186 | let request0: DestroyRegionRequest = DestroyRegionRequest { |
187 | region, |
188 | }; |
189 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
190 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
191 | assert_eq!(slices.len(), bytes.len()); |
192 | conn.send_request_without_reply(&slices, fds) |
193 | } |
194 | |
195 | pub fn set_region<'c, 'input, Conn>(conn: &'c Conn, region: Region, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Conn>, ConnectionError> |
196 | where |
197 | Conn: RequestConnection + ?Sized, |
198 | { |
199 | let request0: SetRegionRequest<'_> = SetRegionRequest { |
200 | region, |
201 | rectangles: Cow::Borrowed(rectangles), |
202 | }; |
203 | let (bytes: [Cow<'_, [u8]>; 3], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
204 | let slices: [IoSlice<'_>; 3] = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])]; |
205 | assert_eq!(slices.len(), bytes.len()); |
206 | conn.send_request_without_reply(&slices, fds) |
207 | } |
208 | |
209 | pub fn copy_region<Conn>(conn: &Conn, source: Region, destination: Region) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
210 | where |
211 | Conn: RequestConnection + ?Sized, |
212 | { |
213 | let request0: CopyRegionRequest = CopyRegionRequest { |
214 | source, |
215 | destination, |
216 | }; |
217 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
218 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
219 | assert_eq!(slices.len(), bytes.len()); |
220 | conn.send_request_without_reply(&slices, fds) |
221 | } |
222 | |
223 | pub fn union_region<Conn>(conn: &Conn, source1: Region, source2: Region, destination: Region) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
224 | where |
225 | Conn: RequestConnection + ?Sized, |
226 | { |
227 | let request0: UnionRegionRequest = UnionRegionRequest { |
228 | source1, |
229 | source2, |
230 | destination, |
231 | }; |
232 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
233 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
234 | assert_eq!(slices.len(), bytes.len()); |
235 | conn.send_request_without_reply(&slices, fds) |
236 | } |
237 | |
238 | pub fn intersect_region<Conn>(conn: &Conn, source1: Region, source2: Region, destination: Region) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
239 | where |
240 | Conn: RequestConnection + ?Sized, |
241 | { |
242 | let request0: IntersectRegionRequest = IntersectRegionRequest { |
243 | source1, |
244 | source2, |
245 | destination, |
246 | }; |
247 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
248 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
249 | assert_eq!(slices.len(), bytes.len()); |
250 | conn.send_request_without_reply(&slices, fds) |
251 | } |
252 | |
253 | pub fn subtract_region<Conn>(conn: &Conn, source1: Region, source2: Region, destination: Region) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
254 | where |
255 | Conn: RequestConnection + ?Sized, |
256 | { |
257 | let request0: SubtractRegionRequest = SubtractRegionRequest { |
258 | source1, |
259 | source2, |
260 | destination, |
261 | }; |
262 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
263 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
264 | assert_eq!(slices.len(), bytes.len()); |
265 | conn.send_request_without_reply(&slices, fds) |
266 | } |
267 | |
268 | pub fn invert_region<Conn>(conn: &Conn, source: Region, bounds: xproto::Rectangle, destination: Region) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
269 | where |
270 | Conn: RequestConnection + ?Sized, |
271 | { |
272 | let request0: InvertRegionRequest = InvertRegionRequest { |
273 | source, |
274 | bounds, |
275 | destination, |
276 | }; |
277 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
278 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
279 | assert_eq!(slices.len(), bytes.len()); |
280 | conn.send_request_without_reply(&slices, fds) |
281 | } |
282 | |
283 | pub fn translate_region<Conn>(conn: &Conn, region: Region, dx: i16, dy: i16) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
284 | where |
285 | Conn: RequestConnection + ?Sized, |
286 | { |
287 | let request0: TranslateRegionRequest = TranslateRegionRequest { |
288 | region, |
289 | dx, |
290 | dy, |
291 | }; |
292 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
293 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
294 | assert_eq!(slices.len(), bytes.len()); |
295 | conn.send_request_without_reply(&slices, fds) |
296 | } |
297 | |
298 | pub fn region_extents<Conn>(conn: &Conn, source: Region, destination: Region) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
299 | where |
300 | Conn: RequestConnection + ?Sized, |
301 | { |
302 | let request0: RegionExtentsRequest = RegionExtentsRequest { |
303 | source, |
304 | destination, |
305 | }; |
306 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
307 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
308 | assert_eq!(slices.len(), bytes.len()); |
309 | conn.send_request_without_reply(&slices, fds) |
310 | } |
311 | |
312 | pub fn fetch_region<Conn>(conn: &Conn, region: Region) -> Result<Cookie<'_, Conn, FetchRegionReply>, ConnectionError> |
313 | where |
314 | Conn: RequestConnection + ?Sized, |
315 | { |
316 | let request0: FetchRegionRequest = FetchRegionRequest { |
317 | region, |
318 | }; |
319 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
320 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
321 | assert_eq!(slices.len(), bytes.len()); |
322 | conn.send_request_with_reply(&slices, fds) |
323 | } |
324 | |
325 | pub fn set_gc_clip_region<Conn, A>(conn: &Conn, gc: xproto::Gcontext, region: A, x_origin: i16, y_origin: i16) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
326 | where |
327 | Conn: RequestConnection + ?Sized, |
328 | A: Into<Region>, |
329 | { |
330 | let region: Region = region.into(); |
331 | let request0: SetGCClipRegionRequest = SetGCClipRegionRequest { |
332 | gc, |
333 | region, |
334 | x_origin, |
335 | y_origin, |
336 | }; |
337 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
338 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
339 | assert_eq!(slices.len(), bytes.len()); |
340 | conn.send_request_without_reply(&slices, fds) |
341 | } |
342 | |
343 | pub fn set_window_shape_region<Conn, A>(conn: &Conn, dest: xproto::Window, dest_kind: shape::SK, x_offset: i16, y_offset: i16, region: A) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
344 | where |
345 | Conn: RequestConnection + ?Sized, |
346 | A: Into<Region>, |
347 | { |
348 | let region: Region = region.into(); |
349 | let request0: SetWindowShapeRegionRequest = SetWindowShapeRegionRequest { |
350 | dest, |
351 | dest_kind, |
352 | x_offset, |
353 | y_offset, |
354 | region, |
355 | }; |
356 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
357 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
358 | assert_eq!(slices.len(), bytes.len()); |
359 | conn.send_request_without_reply(&slices, fds) |
360 | } |
361 | |
362 | pub fn set_picture_clip_region<Conn, A>(conn: &Conn, picture: render::Picture, region: A, x_origin: i16, y_origin: i16) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
363 | where |
364 | Conn: RequestConnection + ?Sized, |
365 | A: Into<Region>, |
366 | { |
367 | let region: Region = region.into(); |
368 | let request0: SetPictureClipRegionRequest = SetPictureClipRegionRequest { |
369 | picture, |
370 | region, |
371 | x_origin, |
372 | y_origin, |
373 | }; |
374 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
375 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
376 | assert_eq!(slices.len(), bytes.len()); |
377 | conn.send_request_without_reply(&slices, fds) |
378 | } |
379 | |
380 | pub fn set_cursor_name<'c, 'input, Conn>(conn: &'c Conn, cursor: xproto::Cursor, name: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> |
381 | where |
382 | Conn: RequestConnection + ?Sized, |
383 | { |
384 | let request0: SetCursorNameRequest<'_> = SetCursorNameRequest { |
385 | cursor, |
386 | name: Cow::Borrowed(name), |
387 | }; |
388 | let (bytes: [Cow<'_, [u8]>; 3], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
389 | let slices: [IoSlice<'_>; 3] = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])]; |
390 | assert_eq!(slices.len(), bytes.len()); |
391 | conn.send_request_without_reply(&slices, fds) |
392 | } |
393 | |
394 | pub fn get_cursor_name<Conn>(conn: &Conn, cursor: xproto::Cursor) -> Result<Cookie<'_, Conn, GetCursorNameReply>, ConnectionError> |
395 | where |
396 | Conn: RequestConnection + ?Sized, |
397 | { |
398 | let request0: GetCursorNameRequest = GetCursorNameRequest { |
399 | cursor, |
400 | }; |
401 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
402 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
403 | assert_eq!(slices.len(), bytes.len()); |
404 | conn.send_request_with_reply(&slices, fds) |
405 | } |
406 | |
407 | pub fn get_cursor_image_and_name<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetCursorImageAndNameReply>, ConnectionError> |
408 | where |
409 | Conn: RequestConnection + ?Sized, |
410 | { |
411 | let request0: GetCursorImageAndNameRequest = GetCursorImageAndNameRequest; |
412 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
413 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
414 | assert_eq!(slices.len(), bytes.len()); |
415 | conn.send_request_with_reply(&slices, fds) |
416 | } |
417 | |
418 | pub fn change_cursor<Conn>(conn: &Conn, source: xproto::Cursor, destination: xproto::Cursor) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
419 | where |
420 | Conn: RequestConnection + ?Sized, |
421 | { |
422 | let request0: ChangeCursorRequest = ChangeCursorRequest { |
423 | source, |
424 | destination, |
425 | }; |
426 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
427 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
428 | assert_eq!(slices.len(), bytes.len()); |
429 | conn.send_request_without_reply(&slices, fds) |
430 | } |
431 | |
432 | pub fn change_cursor_by_name<'c, 'input, Conn>(conn: &'c Conn, src: xproto::Cursor, name: &'input [u8]) -> Result<VoidCookie<'c, Conn>, ConnectionError> |
433 | where |
434 | Conn: RequestConnection + ?Sized, |
435 | { |
436 | let request0: ChangeCursorByNameRequest<'_> = ChangeCursorByNameRequest { |
437 | src, |
438 | name: Cow::Borrowed(name), |
439 | }; |
440 | let (bytes: [Cow<'_, [u8]>; 3], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
441 | let slices: [IoSlice<'_>; 3] = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])]; |
442 | assert_eq!(slices.len(), bytes.len()); |
443 | conn.send_request_without_reply(&slices, fds) |
444 | } |
445 | |
446 | pub fn expand_region<Conn>(conn: &Conn, source: Region, destination: Region, left: u16, right: u16, top: u16, bottom: u16) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
447 | where |
448 | Conn: RequestConnection + ?Sized, |
449 | { |
450 | let request0: ExpandRegionRequest = ExpandRegionRequest { |
451 | source, |
452 | destination, |
453 | left, |
454 | right, |
455 | top, |
456 | bottom, |
457 | }; |
458 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
459 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
460 | assert_eq!(slices.len(), bytes.len()); |
461 | conn.send_request_without_reply(&slices, fds) |
462 | } |
463 | |
464 | pub fn hide_cursor<Conn>(conn: &Conn, window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
465 | where |
466 | Conn: RequestConnection + ?Sized, |
467 | { |
468 | let request0: HideCursorRequest = HideCursorRequest { |
469 | window, |
470 | }; |
471 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
472 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
473 | assert_eq!(slices.len(), bytes.len()); |
474 | conn.send_request_without_reply(&slices, fds) |
475 | } |
476 | |
477 | pub fn show_cursor<Conn>(conn: &Conn, window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
478 | where |
479 | Conn: RequestConnection + ?Sized, |
480 | { |
481 | let request0: ShowCursorRequest = ShowCursorRequest { |
482 | window, |
483 | }; |
484 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
485 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
486 | assert_eq!(slices.len(), bytes.len()); |
487 | conn.send_request_without_reply(&slices, fds) |
488 | } |
489 | |
490 | pub fn create_pointer_barrier<'c, 'input, Conn>(conn: &'c Conn, barrier: Barrier, window: xproto::Window, x1: u16, y1: u16, x2: u16, y2: u16, directions: BarrierDirections, devices: &'input [u16]) -> Result<VoidCookie<'c, Conn>, ConnectionError> |
491 | where |
492 | Conn: RequestConnection + ?Sized, |
493 | { |
494 | let request0: CreatePointerBarrierRequest<'_> = CreatePointerBarrierRequest { |
495 | barrier, |
496 | window, |
497 | x1, |
498 | y1, |
499 | x2, |
500 | y2, |
501 | directions, |
502 | devices: Cow::Borrowed(devices), |
503 | }; |
504 | let (bytes: [Cow<'_, [u8]>; 3], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
505 | let slices: [IoSlice<'_>; 3] = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])]; |
506 | assert_eq!(slices.len(), bytes.len()); |
507 | conn.send_request_without_reply(&slices, fds) |
508 | } |
509 | |
510 | pub fn delete_pointer_barrier<Conn>(conn: &Conn, barrier: Barrier) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
511 | where |
512 | Conn: RequestConnection + ?Sized, |
513 | { |
514 | let request0: DeletePointerBarrierRequest = DeletePointerBarrierRequest { |
515 | barrier, |
516 | }; |
517 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
518 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
519 | assert_eq!(slices.len(), bytes.len()); |
520 | conn.send_request_without_reply(&slices, fds) |
521 | } |
522 | |
523 | /// Sets the disconnect mode for the client.. |
524 | /// |
525 | /// # Fields |
526 | /// |
527 | /// * `disconnect_mode` - The new disconnect mode. |
528 | pub fn set_client_disconnect_mode<Conn>(conn: &Conn, disconnect_mode: ClientDisconnectFlags) -> Result<VoidCookie<'_, Conn>, ConnectionError> |
529 | where |
530 | Conn: RequestConnection + ?Sized, |
531 | { |
532 | let request0: SetClientDisconnectModeRequest = SetClientDisconnectModeRequest { |
533 | disconnect_mode, |
534 | }; |
535 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
536 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
537 | assert_eq!(slices.len(), bytes.len()); |
538 | conn.send_request_without_reply(&slices, fds) |
539 | } |
540 | |
541 | pub fn get_client_disconnect_mode<Conn>(conn: &Conn) -> Result<Cookie<'_, Conn, GetClientDisconnectModeReply>, ConnectionError> |
542 | where |
543 | Conn: RequestConnection + ?Sized, |
544 | { |
545 | let request0: GetClientDisconnectModeRequest = GetClientDisconnectModeRequest; |
546 | let (bytes: [Cow<'_, [u8]>; 1], fds: Vec) = request0.serialize(major_opcode:major_opcode(conn)?); |
547 | let slices: [IoSlice<'_>; 1] = [IoSlice::new(&bytes[0])]; |
548 | assert_eq!(slices.len(), bytes.len()); |
549 | conn.send_request_with_reply(&slices, fds) |
550 | } |
551 | |
552 | /// Extension trait defining the requests of this extension. |
553 | pub trait ConnectionExt: RequestConnection { |
554 | fn xfixes_query_version(&self, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError> |
555 | { |
556 | query_version(self, client_major_version, client_minor_version) |
557 | } |
558 | fn xfixes_change_save_set(&self, mode: SaveSetMode, target: SaveSetTarget, map: SaveSetMapping, window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError> |
559 | { |
560 | change_save_set(self, mode, target, map, window) |
561 | } |
562 | fn xfixes_select_selection_input(&self, window: xproto::Window, selection: xproto::Atom, event_mask: SelectionEventMask) -> Result<VoidCookie<'_, Self>, ConnectionError> |
563 | { |
564 | select_selection_input(self, window, selection, event_mask) |
565 | } |
566 | fn xfixes_select_cursor_input(&self, window: xproto::Window, event_mask: CursorNotifyMask) -> Result<VoidCookie<'_, Self>, ConnectionError> |
567 | { |
568 | select_cursor_input(self, window, event_mask) |
569 | } |
570 | fn xfixes_get_cursor_image(&self) -> Result<Cookie<'_, Self, GetCursorImageReply>, ConnectionError> |
571 | { |
572 | get_cursor_image(self) |
573 | } |
574 | fn xfixes_create_region<'c, 'input>(&'c self, region: Region, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError> |
575 | { |
576 | create_region(self, region, rectangles) |
577 | } |
578 | fn xfixes_create_region_from_bitmap(&self, region: Region, bitmap: xproto::Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError> |
579 | { |
580 | create_region_from_bitmap(self, region, bitmap) |
581 | } |
582 | fn xfixes_create_region_from_window(&self, region: Region, window: xproto::Window, kind: shape::SK) -> Result<VoidCookie<'_, Self>, ConnectionError> |
583 | { |
584 | create_region_from_window(self, region, window, kind) |
585 | } |
586 | fn xfixes_create_region_from_gc(&self, region: Region, gc: xproto::Gcontext) -> Result<VoidCookie<'_, Self>, ConnectionError> |
587 | { |
588 | create_region_from_gc(self, region, gc) |
589 | } |
590 | fn xfixes_create_region_from_picture(&self, region: Region, picture: render::Picture) -> Result<VoidCookie<'_, Self>, ConnectionError> |
591 | { |
592 | create_region_from_picture(self, region, picture) |
593 | } |
594 | fn xfixes_destroy_region(&self, region: Region) -> Result<VoidCookie<'_, Self>, ConnectionError> |
595 | { |
596 | destroy_region(self, region) |
597 | } |
598 | fn xfixes_set_region<'c, 'input>(&'c self, region: Region, rectangles: &'input [xproto::Rectangle]) -> Result<VoidCookie<'c, Self>, ConnectionError> |
599 | { |
600 | set_region(self, region, rectangles) |
601 | } |
602 | fn xfixes_copy_region(&self, source: Region, destination: Region) -> Result<VoidCookie<'_, Self>, ConnectionError> |
603 | { |
604 | copy_region(self, source, destination) |
605 | } |
606 | fn xfixes_union_region(&self, source1: Region, source2: Region, destination: Region) -> Result<VoidCookie<'_, Self>, ConnectionError> |
607 | { |
608 | union_region(self, source1, source2, destination) |
609 | } |
610 | fn xfixes_intersect_region(&self, source1: Region, source2: Region, destination: Region) -> Result<VoidCookie<'_, Self>, ConnectionError> |
611 | { |
612 | intersect_region(self, source1, source2, destination) |
613 | } |
614 | fn xfixes_subtract_region(&self, source1: Region, source2: Region, destination: Region) -> Result<VoidCookie<'_, Self>, ConnectionError> |
615 | { |
616 | subtract_region(self, source1, source2, destination) |
617 | } |
618 | fn xfixes_invert_region(&self, source: Region, bounds: xproto::Rectangle, destination: Region) -> Result<VoidCookie<'_, Self>, ConnectionError> |
619 | { |
620 | invert_region(self, source, bounds, destination) |
621 | } |
622 | fn xfixes_translate_region(&self, region: Region, dx: i16, dy: i16) -> Result<VoidCookie<'_, Self>, ConnectionError> |
623 | { |
624 | translate_region(self, region, dx, dy) |
625 | } |
626 | fn xfixes_region_extents(&self, source: Region, destination: Region) -> Result<VoidCookie<'_, Self>, ConnectionError> |
627 | { |
628 | region_extents(self, source, destination) |
629 | } |
630 | fn xfixes_fetch_region(&self, region: Region) -> Result<Cookie<'_, Self, FetchRegionReply>, ConnectionError> |
631 | { |
632 | fetch_region(self, region) |
633 | } |
634 | fn xfixes_set_gc_clip_region<A>(&self, gc: xproto::Gcontext, region: A, x_origin: i16, y_origin: i16) -> Result<VoidCookie<'_, Self>, ConnectionError> |
635 | where |
636 | A: Into<Region>, |
637 | { |
638 | set_gc_clip_region(self, gc, region, x_origin, y_origin) |
639 | } |
640 | fn xfixes_set_window_shape_region<A>(&self, dest: xproto::Window, dest_kind: shape::SK, x_offset: i16, y_offset: i16, region: A) -> Result<VoidCookie<'_, Self>, ConnectionError> |
641 | where |
642 | A: Into<Region>, |
643 | { |
644 | set_window_shape_region(self, dest, dest_kind, x_offset, y_offset, region) |
645 | } |
646 | fn xfixes_set_picture_clip_region<A>(&self, picture: render::Picture, region: A, x_origin: i16, y_origin: i16) -> Result<VoidCookie<'_, Self>, ConnectionError> |
647 | where |
648 | A: Into<Region>, |
649 | { |
650 | set_picture_clip_region(self, picture, region, x_origin, y_origin) |
651 | } |
652 | fn xfixes_set_cursor_name<'c, 'input>(&'c self, cursor: xproto::Cursor, name: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError> |
653 | { |
654 | set_cursor_name(self, cursor, name) |
655 | } |
656 | fn xfixes_get_cursor_name(&self, cursor: xproto::Cursor) -> Result<Cookie<'_, Self, GetCursorNameReply>, ConnectionError> |
657 | { |
658 | get_cursor_name(self, cursor) |
659 | } |
660 | fn xfixes_get_cursor_image_and_name(&self) -> Result<Cookie<'_, Self, GetCursorImageAndNameReply>, ConnectionError> |
661 | { |
662 | get_cursor_image_and_name(self) |
663 | } |
664 | fn xfixes_change_cursor(&self, source: xproto::Cursor, destination: xproto::Cursor) -> Result<VoidCookie<'_, Self>, ConnectionError> |
665 | { |
666 | change_cursor(self, source, destination) |
667 | } |
668 | fn xfixes_change_cursor_by_name<'c, 'input>(&'c self, src: xproto::Cursor, name: &'input [u8]) -> Result<VoidCookie<'c, Self>, ConnectionError> |
669 | { |
670 | change_cursor_by_name(self, src, name) |
671 | } |
672 | fn xfixes_expand_region(&self, source: Region, destination: Region, left: u16, right: u16, top: u16, bottom: u16) -> Result<VoidCookie<'_, Self>, ConnectionError> |
673 | { |
674 | expand_region(self, source, destination, left, right, top, bottom) |
675 | } |
676 | fn xfixes_hide_cursor(&self, window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError> |
677 | { |
678 | hide_cursor(self, window) |
679 | } |
680 | fn xfixes_show_cursor(&self, window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError> |
681 | { |
682 | show_cursor(self, window) |
683 | } |
684 | fn xfixes_create_pointer_barrier<'c, 'input>(&'c self, barrier: Barrier, window: xproto::Window, x1: u16, y1: u16, x2: u16, y2: u16, directions: BarrierDirections, devices: &'input [u16]) -> Result<VoidCookie<'c, Self>, ConnectionError> |
685 | { |
686 | create_pointer_barrier(self, barrier, window, x1, y1, x2, y2, directions, devices) |
687 | } |
688 | fn xfixes_delete_pointer_barrier(&self, barrier: Barrier) -> Result<VoidCookie<'_, Self>, ConnectionError> |
689 | { |
690 | delete_pointer_barrier(self, barrier) |
691 | } |
692 | /// Sets the disconnect mode for the client.. |
693 | /// |
694 | /// # Fields |
695 | /// |
696 | /// * `disconnect_mode` - The new disconnect mode. |
697 | fn xfixes_set_client_disconnect_mode(&self, disconnect_mode: ClientDisconnectFlags) -> Result<VoidCookie<'_, Self>, ConnectionError> |
698 | { |
699 | set_client_disconnect_mode(self, disconnect_mode) |
700 | } |
701 | fn xfixes_get_client_disconnect_mode(&self) -> Result<Cookie<'_, Self, GetClientDisconnectModeReply>, ConnectionError> |
702 | { |
703 | get_client_disconnect_mode(self) |
704 | } |
705 | } |
706 | |
707 | impl<C: RequestConnection + ?Sized> ConnectionExt for C {} |
708 | |
709 | /// A RAII-like wrapper around a [Region]. |
710 | /// |
711 | /// Instances of this struct represent a Region that is freed in `Drop`. |
712 | /// |
713 | /// Any errors during `Drop` are silently ignored. Most likely an error here means that your |
714 | /// X11 connection is broken and later requests will also fail. |
715 | #[derive (Debug)] |
716 | pub struct RegionWrapper<C: RequestConnection>(C, Region); |
717 | |
718 | impl<C: RequestConnection> RegionWrapper<C> |
719 | { |
720 | /// Assume ownership of the given resource and destroy it in `Drop`. |
721 | pub fn for_region(conn: C, id: Region) -> Self { |
722 | RegionWrapper(conn, id) |
723 | } |
724 | |
725 | /// Get the XID of the wrapped resource |
726 | pub fn region(&self) -> Region { |
727 | self.1 |
728 | } |
729 | |
730 | /// Assume ownership of the XID of the wrapped resource |
731 | /// |
732 | /// This function destroys this wrapper without freeing the underlying resource. |
733 | pub fn into_region(self) -> Region { |
734 | let id: u32 = self.1; |
735 | std::mem::forget(self); |
736 | id |
737 | } |
738 | } |
739 | |
740 | impl<'c, C: X11Connection> RegionWrapper<&'c C> |
741 | { |
742 | /// Create a new Region and return a Region wrapper and a cookie. |
743 | /// |
744 | /// This is a thin wrapper around [create_region] that allocates an id for the Region. |
745 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
746 | /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to |
747 | /// [create_region]. |
748 | /// |
749 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region]. |
750 | pub fn create_region_and_get_cookie(conn: &'c C, rectangles: &[xproto::Rectangle]) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError> |
751 | { |
752 | let region: u32 = conn.generate_id()?; |
753 | let cookie: VoidCookie<'_, C> = create_region(conn, region, rectangles)?; |
754 | Ok((Self::for_region(conn, id:region), cookie)) |
755 | } |
756 | } |
757 | impl<C: X11Connection> RegionWrapper<C> |
758 | { |
759 | /// Create a new Region and return a Region wrapper |
760 | /// |
761 | /// This is a thin wrapper around [create_region] that allocates an id for the Region. |
762 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
763 | /// it in `Drop`. |
764 | /// |
765 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region]. |
766 | pub fn create_region(conn: C, rectangles: &[xproto::Rectangle]) -> Result<Self, ReplyOrIdError> |
767 | { |
768 | let region: u32 = conn.generate_id()?; |
769 | let _ = create_region(&conn, region, rectangles)?; |
770 | Ok(Self::for_region(conn, id:region)) |
771 | } |
772 | } |
773 | |
774 | impl<'c, C: X11Connection> RegionWrapper<&'c C> |
775 | { |
776 | /// Create a new Region and return a Region wrapper and a cookie. |
777 | /// |
778 | /// This is a thin wrapper around [create_region_from_bitmap] that allocates an id for the Region. |
779 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
780 | /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to |
781 | /// [create_region_from_bitmap]. |
782 | /// |
783 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_bitmap]. |
784 | pub fn create_region_from_bitmap_and_get_cookie(conn: &'c C, bitmap: xproto::Pixmap) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError> |
785 | { |
786 | let region: u32 = conn.generate_id()?; |
787 | let cookie: VoidCookie<'_, C> = create_region_from_bitmap(conn, region, bitmap)?; |
788 | Ok((Self::for_region(conn, id:region), cookie)) |
789 | } |
790 | } |
791 | impl<C: X11Connection> RegionWrapper<C> |
792 | { |
793 | /// Create a new Region and return a Region wrapper |
794 | /// |
795 | /// This is a thin wrapper around [create_region_from_bitmap] that allocates an id for the Region. |
796 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
797 | /// it in `Drop`. |
798 | /// |
799 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_bitmap]. |
800 | pub fn create_region_from_bitmap(conn: C, bitmap: xproto::Pixmap) -> Result<Self, ReplyOrIdError> |
801 | { |
802 | let region: u32 = conn.generate_id()?; |
803 | let _ = create_region_from_bitmap(&conn, region, bitmap)?; |
804 | Ok(Self::for_region(conn, id:region)) |
805 | } |
806 | } |
807 | |
808 | impl<'c, C: X11Connection> RegionWrapper<&'c C> |
809 | { |
810 | /// Create a new Region and return a Region wrapper and a cookie. |
811 | /// |
812 | /// This is a thin wrapper around [create_region_from_window] that allocates an id for the Region. |
813 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
814 | /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to |
815 | /// [create_region_from_window]. |
816 | /// |
817 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_window]. |
818 | pub fn create_region_from_window_and_get_cookie(conn: &'c C, window: xproto::Window, kind: shape::SK) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError> |
819 | { |
820 | let region: u32 = conn.generate_id()?; |
821 | let cookie: VoidCookie<'_, C> = create_region_from_window(conn, region, window, kind)?; |
822 | Ok((Self::for_region(conn, id:region), cookie)) |
823 | } |
824 | } |
825 | impl<C: X11Connection> RegionWrapper<C> |
826 | { |
827 | /// Create a new Region and return a Region wrapper |
828 | /// |
829 | /// This is a thin wrapper around [create_region_from_window] that allocates an id for the Region. |
830 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
831 | /// it in `Drop`. |
832 | /// |
833 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_window]. |
834 | pub fn create_region_from_window(conn: C, window: xproto::Window, kind: shape::SK) -> Result<Self, ReplyOrIdError> |
835 | { |
836 | let region: u32 = conn.generate_id()?; |
837 | let _ = create_region_from_window(&conn, region, window, kind)?; |
838 | Ok(Self::for_region(conn, id:region)) |
839 | } |
840 | } |
841 | |
842 | impl<'c, C: X11Connection> RegionWrapper<&'c C> |
843 | { |
844 | /// Create a new Region and return a Region wrapper and a cookie. |
845 | /// |
846 | /// This is a thin wrapper around [create_region_from_gc] that allocates an id for the Region. |
847 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
848 | /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to |
849 | /// [create_region_from_gc]. |
850 | /// |
851 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_gc]. |
852 | pub fn create_region_from_gc_and_get_cookie(conn: &'c C, gc: xproto::Gcontext) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError> |
853 | { |
854 | let region: u32 = conn.generate_id()?; |
855 | let cookie: VoidCookie<'_, C> = create_region_from_gc(conn, region, gc)?; |
856 | Ok((Self::for_region(conn, id:region), cookie)) |
857 | } |
858 | } |
859 | impl<C: X11Connection> RegionWrapper<C> |
860 | { |
861 | /// Create a new Region and return a Region wrapper |
862 | /// |
863 | /// This is a thin wrapper around [create_region_from_gc] that allocates an id for the Region. |
864 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
865 | /// it in `Drop`. |
866 | /// |
867 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_gc]. |
868 | pub fn create_region_from_gc(conn: C, gc: xproto::Gcontext) -> Result<Self, ReplyOrIdError> |
869 | { |
870 | let region: u32 = conn.generate_id()?; |
871 | let _ = create_region_from_gc(&conn, region, gc)?; |
872 | Ok(Self::for_region(conn, id:region)) |
873 | } |
874 | } |
875 | |
876 | impl<'c, C: X11Connection> RegionWrapper<&'c C> |
877 | { |
878 | /// Create a new Region and return a Region wrapper and a cookie. |
879 | /// |
880 | /// This is a thin wrapper around [create_region_from_picture] that allocates an id for the Region. |
881 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
882 | /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to |
883 | /// [create_region_from_picture]. |
884 | /// |
885 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_picture]. |
886 | pub fn create_region_from_picture_and_get_cookie(conn: &'c C, picture: render::Picture) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError> |
887 | { |
888 | let region: u32 = conn.generate_id()?; |
889 | let cookie: VoidCookie<'_, C> = create_region_from_picture(conn, region, picture)?; |
890 | Ok((Self::for_region(conn, id:region), cookie)) |
891 | } |
892 | } |
893 | impl<C: X11Connection> RegionWrapper<C> |
894 | { |
895 | /// Create a new Region and return a Region wrapper |
896 | /// |
897 | /// This is a thin wrapper around [create_region_from_picture] that allocates an id for the Region. |
898 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
899 | /// it in `Drop`. |
900 | /// |
901 | /// Errors can come from the call to [X11Connection::generate_id] or [create_region_from_picture]. |
902 | pub fn create_region_from_picture(conn: C, picture: render::Picture) -> Result<Self, ReplyOrIdError> |
903 | { |
904 | let region: u32 = conn.generate_id()?; |
905 | let _ = create_region_from_picture(&conn, region, picture)?; |
906 | Ok(Self::for_region(conn, id:region)) |
907 | } |
908 | } |
909 | |
910 | impl<'c, C: X11Connection> RegionWrapper<&'c C> |
911 | { |
912 | /// Create a new Region and return a Region wrapper and a cookie. |
913 | /// |
914 | /// This is a thin wrapper around [super::composite::create_region_from_border_clip] that allocates an id for the Region. |
915 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
916 | /// it in `Drop`. This also returns a `VoidCookie` that comes from the call to |
917 | /// [super::composite::create_region_from_border_clip]. |
918 | /// |
919 | /// Errors can come from the call to [X11Connection::generate_id] or [super::composite::create_region_from_border_clip]. |
920 | #[cfg (feature = "composite" )] |
921 | pub fn composite_create_region_from_border_clip_and_get_cookie(conn: &'c C, window: xproto::Window) -> Result<(Self, VoidCookie<'c, C>), ReplyOrIdError> |
922 | { |
923 | let region = conn.generate_id()?; |
924 | let cookie = super::composite::create_region_from_border_clip(conn, region, window)?; |
925 | Ok((Self::for_region(conn, region), cookie)) |
926 | } |
927 | } |
928 | impl<C: X11Connection> RegionWrapper<C> |
929 | { |
930 | /// Create a new Region and return a Region wrapper |
931 | /// |
932 | /// This is a thin wrapper around [super::composite::create_region_from_border_clip] that allocates an id for the Region. |
933 | /// This function returns the resulting `RegionWrapper` that owns the created Region and frees |
934 | /// it in `Drop`. |
935 | /// |
936 | /// Errors can come from the call to [X11Connection::generate_id] or [super::composite::create_region_from_border_clip]. |
937 | #[cfg (feature = "composite" )] |
938 | pub fn composite_create_region_from_border_clip(conn: C, window: xproto::Window) -> Result<Self, ReplyOrIdError> |
939 | { |
940 | let region = conn.generate_id()?; |
941 | let _ = super::composite::create_region_from_border_clip(&conn, region, window)?; |
942 | Ok(Self::for_region(conn, region)) |
943 | } |
944 | } |
945 | |
946 | #[cfg (feature = "composite" )] |
947 | #[allow (unused_imports)] |
948 | use super::composite; |
949 | impl<C: RequestConnection> From<&RegionWrapper<C>> for Region { |
950 | fn from(from: &RegionWrapper<C>) -> Self { |
951 | from.1 |
952 | } |
953 | } |
954 | |
955 | impl<C: RequestConnection> Drop for RegionWrapper<C> { |
956 | fn drop(&mut self) { |
957 | let _ = destroy_region(&self.0, self.1); |
958 | } |
959 | } |
960 | |