Function lock

Source
pub fn lock(proxy: &impl UntypedBorrowedProxyWrapper) -> BorrowedProxyLock<'_>
Expand description

Locks the proxy for concurrent destruction.

If the proxy is not already destroyed, holding this lock will prevent other threads from destroying it.

Trying to destroy the proxy from this thread while holding this lock will deadlock.

This lock only locks out concurrent destruction. Multiple threads can acquire this lock at the same time.

ยงExample

let lib = Libwayland::open().unwrap();
let con = lib.connect_to_default_display().unwrap();
let queue = con.create_queue(c"");
let display: WlDisplay = queue.display();

// Create a wl_callback that we will destroy in another thread.
let sync1 = display.sync();
let sync2 = sync1.clone();

// Lock the proxy to prevent the other thread from destroying it.
let lock = proxy::lock(&*sync1);

// Create a barrier to synchronize with the other thread.
let barrier1 = Arc::new(Barrier::new(2));
let barrier2 = barrier1.clone();

thread::spawn(move || {
    // This will block until the main thread has released the lock.
    proxy::destroy(&sync2);
    barrier2.wait();
});

// Sleep for a second to demonstrate that the proxy::destroy does in fact not proceed.
thread::sleep(Duration::from_secs(1));

// The other spawned thread has not yet destroyed the proxy.
assert!(lock.wl_proxy().is_some());
// Drop the lock to let the other thread proceed.
drop(lock);

// Wait for the other thread to run to completion.
barrier1.wait();

// The proxy is now destroyed.
assert!(proxy::wl_proxy(&*sync1).is_none());
Examples found in repository?
examples/poll-integration/../common/protocols/wayland/wl_subsurface.rs (line 289)
287    pub fn place_above(&self, sibling: &WlSurfaceRef) {
288        let (arg0,) = (sibling,);
289        let obj0_lock = proxy::lock(arg0);
290        let obj0 = check_argument_proxy("sibling", obj0_lock.wl_proxy());
291        let mut args = [wl_argument { o: obj0 }];
292        // SAFETY: - self.proxy has the interface INTERFACE
293        //         - 2 < INTERFACE.method_count = 6
294        //         - the request signature is `o`
295        unsafe {
296            self.proxy.send_request(2, &mut args);
297        }
298    }
299
300    /// restack the sub-surface
301    ///
302    /// The sub-surface is placed just below the reference surface.
303    /// See wl_subsurface.place_above.
304    ///
305    /// # Arguments
306    ///
307    /// - `sibling`: the reference surface
308    #[inline]
309    pub fn place_below(&self, sibling: &WlSurfaceRef) {
310        let (arg0,) = (sibling,);
311        let obj0_lock = proxy::lock(arg0);
312        let obj0 = check_argument_proxy("sibling", obj0_lock.wl_proxy());
313        let mut args = [wl_argument { o: obj0 }];
314        // SAFETY: - self.proxy has the interface INTERFACE
315        //         - 3 < INTERFACE.method_count = 6
316        //         - the request signature is `o`
317        unsafe {
318            self.proxy.send_request(3, &mut args);
319        }
320    }
More examples
Hide additional examples
examples/poll-integration/../common/protocols/wayland/wl_fixes.rs (line 164)
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    }
examples/poll-integration/../common/protocols/xdg_shell/xdg_popup.rs (line 258)
256    pub fn grab(&self, seat: &WlSeatRef, serial: u32) {
257        let (arg0, arg1) = (seat, serial);
258        let obj0_lock = proxy::lock(arg0);
259        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
260        let mut args = [wl_argument { o: obj0 }, wl_argument { u: arg1 }];
261        // SAFETY: - self.proxy has the interface INTERFACE
262        //         - 1 < INTERFACE.method_count = 3
263        //         - the request signature is `ou`
264        unsafe {
265            self.proxy.send_request(1, &mut args);
266        }
267    }
268
269    /// recalculate the popup's location
270    ///
271    /// Reposition an already-mapped popup. The popup will be placed given the
272    /// details in the passed xdg_positioner object, and a
273    /// xdg_popup.repositioned followed by xdg_popup.configure and
274    /// xdg_surface.configure will be emitted in response. Any parameters set
275    /// by the previous positioner will be discarded.
276    ///
277    /// The passed token will be sent in the corresponding
278    /// xdg_popup.repositioned event. The new popup position will not take
279    /// effect until the corresponding configure event is acknowledged by the
280    /// client. See xdg_popup.repositioned for details. The token itself is
281    /// opaque, and has no other special meaning.
282    ///
283    /// If multiple reposition requests are sent, the compositor may skip all
284    /// but the last one.
285    ///
286    /// If the popup is repositioned in response to a configure event for its
287    /// parent, the client should send an xdg_positioner.set_parent_configure
288    /// and possibly an xdg_positioner.set_parent_size request to allow the
289    /// compositor to properly constrain the popup.
290    ///
291    /// If the popup is repositioned together with a parent that is being
292    /// resized, but not in response to a configure event, the client should
293    /// send an xdg_positioner.set_parent_size request.
294    ///
295    /// # Arguments
296    ///
297    /// - `positioner`:
298    /// - `token`: reposition request token
299    #[inline]
300    pub fn reposition(&self, positioner: &XdgPositionerRef, token: u32) {
301        let (arg0, arg1) = (positioner, token);
302        let obj0_lock = proxy::lock(arg0);
303        let obj0 = check_argument_proxy("positioner", obj0_lock.wl_proxy());
304        let mut args = [wl_argument { o: obj0 }, wl_argument { u: arg1 }];
305        // SAFETY: - self.proxy has the interface INTERFACE
306        //         - 2 < INTERFACE.method_count = 3
307        //         - the request signature is `ou`
308        unsafe {
309            self.proxy.send_request(2, &mut args);
310        }
311    }
examples/poll-integration/../common/protocols/wayland/wl_shell_surface.rs (line 274)
272    pub fn r#move(&self, seat: &WlSeatRef, serial: u32) {
273        let (arg0, arg1) = (seat, serial);
274        let obj0_lock = proxy::lock(arg0);
275        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
276        let mut args = [wl_argument { o: obj0 }, wl_argument { u: arg1 }];
277        // SAFETY: - self.proxy has the interface INTERFACE
278        //         - 1 < INTERFACE.method_count = 10
279        //         - the request signature is `ou`
280        unsafe {
281            self.proxy.send_request(1, &mut args);
282        }
283    }
284
285    /// start an interactive resize
286    ///
287    /// Start a pointer-driven resizing of the surface.
288    ///
289    /// This request must be used in response to a button press event.
290    /// The server may ignore resize requests depending on the state of
291    /// the surface (e.g. fullscreen or maximized).
292    ///
293    /// # Arguments
294    ///
295    /// - `seat`: seat whose pointer is used
296    /// - `serial`: serial number of the implicit grab on the pointer
297    /// - `edges`: which edge or corner is being dragged
298    #[inline]
299    pub fn resize(&self, seat: &WlSeatRef, serial: u32, edges: WlShellSurfaceResize) {
300        let (arg0, arg1, arg2) = (seat, serial, edges);
301        let obj0_lock = proxy::lock(arg0);
302        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
303        let mut args = [
304            wl_argument { o: obj0 },
305            wl_argument { u: arg1 },
306            wl_argument { u: arg2.0 },
307        ];
308        // SAFETY: - self.proxy has the interface INTERFACE
309        //         - 2 < INTERFACE.method_count = 10
310        //         - the request signature is `ouu`
311        unsafe {
312            self.proxy.send_request(2, &mut args);
313        }
314    }
315
316    /// make the surface a toplevel surface
317    ///
318    /// Map the surface as a toplevel surface.
319    ///
320    /// A toplevel surface is not fullscreen, maximized or transient.
321    #[inline]
322    pub fn set_toplevel(&self) {
323        let mut args = [];
324        // SAFETY: - self.proxy has the interface INTERFACE
325        //         - 3 < INTERFACE.method_count = 10
326        //         - the request signature is ``
327        unsafe {
328            self.proxy.send_request(3, &mut args);
329        }
330    }
331
332    /// make the surface a transient surface
333    ///
334    /// Map the surface relative to an existing surface.
335    ///
336    /// The x and y arguments specify the location of the upper left
337    /// corner of the surface relative to the upper left corner of the
338    /// parent surface, in surface-local coordinates.
339    ///
340    /// The flags argument controls details of the transient behaviour.
341    ///
342    /// # Arguments
343    ///
344    /// - `parent`: parent surface
345    /// - `x`: surface-local x coordinate
346    /// - `y`: surface-local y coordinate
347    /// - `flags`: transient surface behavior
348    #[inline]
349    pub fn set_transient(
350        &self,
351        parent: &WlSurfaceRef,
352        x: i32,
353        y: i32,
354        flags: WlShellSurfaceTransient,
355    ) {
356        let (arg0, arg1, arg2, arg3) = (parent, x, y, flags);
357        let obj0_lock = proxy::lock(arg0);
358        let obj0 = check_argument_proxy("parent", obj0_lock.wl_proxy());
359        let mut args = [
360            wl_argument { o: obj0 },
361            wl_argument { i: arg1 },
362            wl_argument { i: arg2 },
363            wl_argument { u: arg3.0 },
364        ];
365        // SAFETY: - self.proxy has the interface INTERFACE
366        //         - 4 < INTERFACE.method_count = 10
367        //         - the request signature is `oiiu`
368        unsafe {
369            self.proxy.send_request(4, &mut args);
370        }
371    }
372
373    /// make the surface a fullscreen surface
374    ///
375    /// Map the surface as a fullscreen surface.
376    ///
377    /// If an output parameter is given then the surface will be made
378    /// fullscreen on that output. If the client does not specify the
379    /// output then the compositor will apply its policy - usually
380    /// choosing the output on which the surface has the biggest surface
381    /// area.
382    ///
383    /// The client may specify a method to resolve a size conflict
384    /// between the output size and the surface size - this is provided
385    /// through the method parameter.
386    ///
387    /// The framerate parameter is used only when the method is set
388    /// to "driver", to indicate the preferred framerate. A value of 0
389    /// indicates that the client does not care about framerate.  The
390    /// framerate is specified in mHz, that is framerate of 60000 is 60Hz.
391    ///
392    /// A method of "scale" or "driver" implies a scaling operation of
393    /// the surface, either via a direct scaling operation or a change of
394    /// the output mode. This will override any kind of output scaling, so
395    /// that mapping a surface with a buffer size equal to the mode can
396    /// fill the screen independent of buffer_scale.
397    ///
398    /// A method of "fill" means we don't scale up the buffer, however
399    /// any output scale is applied. This means that you may run into
400    /// an edge case where the application maps a buffer with the same
401    /// size of the output mode but buffer_scale 1 (thus making a
402    /// surface larger than the output). In this case it is allowed to
403    /// downscale the results to fit the screen.
404    ///
405    /// The compositor must reply to this request with a configure event
406    /// with the dimensions for the output on which the surface will
407    /// be made fullscreen.
408    ///
409    /// # Arguments
410    ///
411    /// - `method`: method for resolving size conflict
412    /// - `framerate`: framerate in mHz
413    /// - `output`: output on which the surface is to be fullscreen
414    #[inline]
415    pub fn set_fullscreen(
416        &self,
417        method: WlShellSurfaceFullscreenMethod,
418        framerate: u32,
419        output: Option<&WlOutputRef>,
420    ) {
421        let (arg0, arg1, arg2) = (method, framerate, output);
422        let obj2_lock = arg2.map(|arg2| proxy::lock(arg2));
423        let obj2 = obj2_lock
424            .map(|obj2_lock| check_argument_proxy("output", obj2_lock.wl_proxy()))
425            .unwrap_or(ptr::null_mut());
426        let mut args = [
427            wl_argument { u: arg0.0 },
428            wl_argument { u: arg1 },
429            wl_argument { o: obj2 },
430        ];
431        // SAFETY: - self.proxy has the interface INTERFACE
432        //         - 5 < INTERFACE.method_count = 10
433        //         - the request signature is `uu?o`
434        unsafe {
435            self.proxy.send_request(5, &mut args);
436        }
437    }
438
439    /// make the surface a popup surface
440    ///
441    /// Map the surface as a popup.
442    ///
443    /// A popup surface is a transient surface with an added pointer
444    /// grab.
445    ///
446    /// An existing implicit grab will be changed to owner-events mode,
447    /// and the popup grab will continue after the implicit grab ends
448    /// (i.e. releasing the mouse button does not cause the popup to
449    /// be unmapped).
450    ///
451    /// The popup grab continues until the window is destroyed or a
452    /// mouse button is pressed in any other client's window. A click
453    /// in any of the client's surfaces is reported as normal, however,
454    /// clicks in other clients' surfaces will be discarded and trigger
455    /// the callback.
456    ///
457    /// The x and y arguments specify the location of the upper left
458    /// corner of the surface relative to the upper left corner of the
459    /// parent surface, in surface-local coordinates.
460    ///
461    /// # Arguments
462    ///
463    /// - `seat`: seat whose pointer is used
464    /// - `serial`: serial number of the implicit grab on the pointer
465    /// - `parent`: parent surface
466    /// - `x`: surface-local x coordinate
467    /// - `y`: surface-local y coordinate
468    /// - `flags`: transient surface behavior
469    #[inline]
470    pub fn set_popup(
471        &self,
472        seat: &WlSeatRef,
473        serial: u32,
474        parent: &WlSurfaceRef,
475        x: i32,
476        y: i32,
477        flags: WlShellSurfaceTransient,
478    ) {
479        let (arg0, arg1, arg2, arg3, arg4, arg5) = (seat, serial, parent, x, y, flags);
480        let obj0_lock = proxy::lock(arg0);
481        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
482        let obj2_lock = proxy::lock(arg2);
483        let obj2 = check_argument_proxy("parent", obj2_lock.wl_proxy());
484        let mut args = [
485            wl_argument { o: obj0 },
486            wl_argument { u: arg1 },
487            wl_argument { o: obj2 },
488            wl_argument { i: arg3 },
489            wl_argument { i: arg4 },
490            wl_argument { u: arg5.0 },
491        ];
492        // SAFETY: - self.proxy has the interface INTERFACE
493        //         - 6 < INTERFACE.method_count = 10
494        //         - the request signature is `ouoiiu`
495        unsafe {
496            self.proxy.send_request(6, &mut args);
497        }
498    }
499
500    /// make the surface a maximized surface
501    ///
502    /// Map the surface as a maximized surface.
503    ///
504    /// If an output parameter is given then the surface will be
505    /// maximized on that output. If the client does not specify the
506    /// output then the compositor will apply its policy - usually
507    /// choosing the output on which the surface has the biggest surface
508    /// area.
509    ///
510    /// The compositor will reply with a configure event telling
511    /// the expected new surface size. The operation is completed
512    /// on the next buffer attach to this surface.
513    ///
514    /// A maximized surface typically fills the entire output it is
515    /// bound to, except for desktop elements such as panels. This is
516    /// the main difference between a maximized shell surface and a
517    /// fullscreen shell surface.
518    ///
519    /// The details depend on the compositor implementation.
520    ///
521    /// # Arguments
522    ///
523    /// - `output`: output on which the surface is to be maximized
524    #[inline]
525    pub fn set_maximized(&self, output: Option<&WlOutputRef>) {
526        let (arg0,) = (output,);
527        let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
528        let obj0 = obj0_lock
529            .map(|obj0_lock| check_argument_proxy("output", obj0_lock.wl_proxy()))
530            .unwrap_or(ptr::null_mut());
531        let mut args = [wl_argument { o: obj0 }];
532        // SAFETY: - self.proxy has the interface INTERFACE
533        //         - 7 < INTERFACE.method_count = 10
534        //         - the request signature is `?o`
535        unsafe {
536            self.proxy.send_request(7, &mut args);
537        }
538    }
examples/poll-integration/../common/protocols/xdg_shell/xdg_toplevel.rs (line 333)
331    pub fn set_parent(&self, parent: Option<&XdgToplevelRef>) {
332        let (arg0,) = (parent,);
333        let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
334        let obj0 = obj0_lock
335            .map(|obj0_lock| check_argument_proxy("parent", obj0_lock.wl_proxy()))
336            .unwrap_or(ptr::null_mut());
337        let mut args = [wl_argument { o: obj0 }];
338        // SAFETY: - self.proxy has the interface INTERFACE
339        //         - 1 < INTERFACE.method_count = 14
340        //         - the request signature is `?o`
341        unsafe {
342            self.proxy.send_request(1, &mut args);
343        }
344    }
345
346    /// set surface title
347    ///
348    /// Set a short title for the surface.
349    ///
350    /// This string may be used to identify the surface in a task bar,
351    /// window list, or other user interface elements provided by the
352    /// compositor.
353    ///
354    /// The string must be encoded in UTF-8.
355    ///
356    /// # Arguments
357    ///
358    /// - `title`:
359    #[inline]
360    pub fn set_title(&self, title: &str) {
361        let (arg0,) = (title,);
362        with_cstr_cache(|cache| {
363            let str0_offset = cache.len();
364            cache.extend_from_slice(arg0.as_bytes());
365            cache.push(0);
366            let str0 = cache[str0_offset..].as_ptr().cast();
367            let mut args = [wl_argument { s: str0 }];
368            // SAFETY: - self.proxy has the interface INTERFACE
369            //         - 2 < INTERFACE.method_count = 14
370            //         - the request signature is `s`
371            unsafe {
372                self.proxy.send_request(2, &mut args);
373            }
374        })
375    }
376
377    /// set application ID
378    ///
379    /// Set an application identifier for the surface.
380    ///
381    /// The app ID identifies the general class of applications to which
382    /// the surface belongs. The compositor can use this to group multiple
383    /// surfaces together, or to determine how to launch a new application.
384    ///
385    /// For D-Bus activatable applications, the app ID is used as the D-Bus
386    /// service name.
387    ///
388    /// The compositor shell will try to group application surfaces together
389    /// by their app ID. As a best practice, it is suggested to select app
390    /// ID's that match the basename of the application's .desktop file.
391    /// For example, "org.freedesktop.FooViewer" where the .desktop file is
392    /// "org.freedesktop.FooViewer.desktop".
393    ///
394    /// Like other properties, a set_app_id request can be sent after the
395    /// xdg_toplevel has been mapped to update the property.
396    ///
397    /// See the desktop-entry specification [0] for more details on
398    /// application identifiers and how they relate to well-known D-Bus
399    /// names and .desktop files.
400    ///
401    /// [0] https://standards.freedesktop.org/desktop-entry-spec/
402    ///
403    /// # Arguments
404    ///
405    /// - `app_id`:
406    #[inline]
407    pub fn set_app_id(&self, app_id: &str) {
408        let (arg0,) = (app_id,);
409        with_cstr_cache(|cache| {
410            let str0_offset = cache.len();
411            cache.extend_from_slice(arg0.as_bytes());
412            cache.push(0);
413            let str0 = cache[str0_offset..].as_ptr().cast();
414            let mut args = [wl_argument { s: str0 }];
415            // SAFETY: - self.proxy has the interface INTERFACE
416            //         - 3 < INTERFACE.method_count = 14
417            //         - the request signature is `s`
418            unsafe {
419                self.proxy.send_request(3, &mut args);
420            }
421        })
422    }
423
424    /// show the window menu
425    ///
426    /// Clients implementing client-side decorations might want to show
427    /// a context menu when right-clicking on the decorations, giving the
428    /// user a menu that they can use to maximize or minimize the window.
429    ///
430    /// This request asks the compositor to pop up such a window menu at
431    /// the given position, relative to the local surface coordinates of
432    /// the parent surface. There are no guarantees as to what menu items
433    /// the window menu contains, or even if a window menu will be drawn
434    /// at all.
435    ///
436    /// This request must be used in response to some sort of user action
437    /// like a button press, key press, or touch down event.
438    ///
439    /// # Arguments
440    ///
441    /// - `seat`: the wl_seat of the user event
442    /// - `serial`: the serial of the user event
443    /// - `x`: the x position to pop up the window menu at
444    /// - `y`: the y position to pop up the window menu at
445    #[inline]
446    pub fn show_window_menu(&self, seat: &WlSeatRef, serial: u32, x: i32, y: i32) {
447        let (arg0, arg1, arg2, arg3) = (seat, serial, x, y);
448        let obj0_lock = proxy::lock(arg0);
449        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
450        let mut args = [
451            wl_argument { o: obj0 },
452            wl_argument { u: arg1 },
453            wl_argument { i: arg2 },
454            wl_argument { i: arg3 },
455        ];
456        // SAFETY: - self.proxy has the interface INTERFACE
457        //         - 4 < INTERFACE.method_count = 14
458        //         - the request signature is `ouii`
459        unsafe {
460            self.proxy.send_request(4, &mut args);
461        }
462    }
463
464    /// start an interactive move
465    ///
466    /// Start an interactive, user-driven move of the surface.
467    ///
468    /// This request must be used in response to some sort of user action
469    /// like a button press, key press, or touch down event. The passed
470    /// serial is used to determine the type of interactive move (touch,
471    /// pointer, etc).
472    ///
473    /// The server may ignore move requests depending on the state of
474    /// the surface (e.g. fullscreen or maximized), or if the passed serial
475    /// is no longer valid.
476    ///
477    /// If triggered, the surface will lose the focus of the device
478    /// (wl_pointer, wl_touch, etc) used for the move. It is up to the
479    /// compositor to visually indicate that the move is taking place, such as
480    /// updating a pointer cursor, during the move. There is no guarantee
481    /// that the device focus will return when the move is completed.
482    ///
483    /// # Arguments
484    ///
485    /// - `seat`: the wl_seat of the user event
486    /// - `serial`: the serial of the user event
487    #[inline]
488    pub fn r#move(&self, seat: &WlSeatRef, serial: u32) {
489        let (arg0, arg1) = (seat, serial);
490        let obj0_lock = proxy::lock(arg0);
491        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
492        let mut args = [wl_argument { o: obj0 }, wl_argument { u: arg1 }];
493        // SAFETY: - self.proxy has the interface INTERFACE
494        //         - 5 < INTERFACE.method_count = 14
495        //         - the request signature is `ou`
496        unsafe {
497            self.proxy.send_request(5, &mut args);
498        }
499    }
500
501    /// start an interactive resize
502    ///
503    /// Start a user-driven, interactive resize of the surface.
504    ///
505    /// This request must be used in response to some sort of user action
506    /// like a button press, key press, or touch down event. The passed
507    /// serial is used to determine the type of interactive resize (touch,
508    /// pointer, etc).
509    ///
510    /// The server may ignore resize requests depending on the state of
511    /// the surface (e.g. fullscreen or maximized).
512    ///
513    /// If triggered, the client will receive configure events with the
514    /// "resize" state enum value and the expected sizes. See the "resize"
515    /// enum value for more details about what is required. The client
516    /// must also acknowledge configure events using "ack_configure". After
517    /// the resize is completed, the client will receive another "configure"
518    /// event without the resize state.
519    ///
520    /// If triggered, the surface also will lose the focus of the device
521    /// (wl_pointer, wl_touch, etc) used for the resize. It is up to the
522    /// compositor to visually indicate that the resize is taking place,
523    /// such as updating a pointer cursor, during the resize. There is no
524    /// guarantee that the device focus will return when the resize is
525    /// completed.
526    ///
527    /// The edges parameter specifies how the surface should be resized, and
528    /// is one of the values of the resize_edge enum. Values not matching
529    /// a variant of the enum will cause the invalid_resize_edge protocol error.
530    /// The compositor may use this information to update the surface position
531    /// for example when dragging the top left corner. The compositor may also
532    /// use this information to adapt its behavior, e.g. choose an appropriate
533    /// cursor image.
534    ///
535    /// # Arguments
536    ///
537    /// - `seat`: the wl_seat of the user event
538    /// - `serial`: the serial of the user event
539    /// - `edges`: which edge or corner is being dragged
540    #[inline]
541    pub fn resize(&self, seat: &WlSeatRef, serial: u32, edges: XdgToplevelResizeEdge) {
542        let (arg0, arg1, arg2) = (seat, serial, edges);
543        let obj0_lock = proxy::lock(arg0);
544        let obj0 = check_argument_proxy("seat", obj0_lock.wl_proxy());
545        let mut args = [
546            wl_argument { o: obj0 },
547            wl_argument { u: arg1 },
548            wl_argument { u: arg2.0 },
549        ];
550        // SAFETY: - self.proxy has the interface INTERFACE
551        //         - 6 < INTERFACE.method_count = 14
552        //         - the request signature is `ouu`
553        unsafe {
554            self.proxy.send_request(6, &mut args);
555        }
556    }
557
558    /// set the maximum size
559    ///
560    /// Set a maximum size for the window.
561    ///
562    /// The client can specify a maximum size so that the compositor does
563    /// not try to configure the window beyond this size.
564    ///
565    /// The width and height arguments are in window geometry coordinates.
566    /// See xdg_surface.set_window_geometry.
567    ///
568    /// Values set in this way are double-buffered, see wl_surface.commit.
569    ///
570    /// The compositor can use this information to allow or disallow
571    /// different states like maximize or fullscreen and draw accurate
572    /// animations.
573    ///
574    /// Similarly, a tiling window manager may use this information to
575    /// place and resize client windows in a more effective way.
576    ///
577    /// The client should not rely on the compositor to obey the maximum
578    /// size. The compositor may decide to ignore the values set by the
579    /// client and request a larger size.
580    ///
581    /// If never set, or a value of zero in the request, means that the
582    /// client has no expected maximum size in the given dimension.
583    /// As a result, a client wishing to reset the maximum size
584    /// to an unspecified state can use zero for width and height in the
585    /// request.
586    ///
587    /// Requesting a maximum size to be smaller than the minimum size of
588    /// a surface is illegal and will result in an invalid_size error.
589    ///
590    /// The width and height must be greater than or equal to zero. Using
591    /// strictly negative values for width or height will result in a
592    /// invalid_size error.
593    ///
594    /// # Arguments
595    ///
596    /// - `width`:
597    /// - `height`:
598    #[inline]
599    pub fn set_max_size(&self, width: i32, height: i32) {
600        let (arg0, arg1) = (width, height);
601        let mut args = [wl_argument { i: arg0 }, wl_argument { i: arg1 }];
602        // SAFETY: - self.proxy has the interface INTERFACE
603        //         - 7 < INTERFACE.method_count = 14
604        //         - the request signature is `ii`
605        unsafe {
606            self.proxy.send_request(7, &mut args);
607        }
608    }
609
610    /// set the minimum size
611    ///
612    /// Set a minimum size for the window.
613    ///
614    /// The client can specify a minimum size so that the compositor does
615    /// not try to configure the window below this size.
616    ///
617    /// The width and height arguments are in window geometry coordinates.
618    /// See xdg_surface.set_window_geometry.
619    ///
620    /// Values set in this way are double-buffered, see wl_surface.commit.
621    ///
622    /// The compositor can use this information to allow or disallow
623    /// different states like maximize or fullscreen and draw accurate
624    /// animations.
625    ///
626    /// Similarly, a tiling window manager may use this information to
627    /// place and resize client windows in a more effective way.
628    ///
629    /// The client should not rely on the compositor to obey the minimum
630    /// size. The compositor may decide to ignore the values set by the
631    /// client and request a smaller size.
632    ///
633    /// If never set, or a value of zero in the request, means that the
634    /// client has no expected minimum size in the given dimension.
635    /// As a result, a client wishing to reset the minimum size
636    /// to an unspecified state can use zero for width and height in the
637    /// request.
638    ///
639    /// Requesting a minimum size to be larger than the maximum size of
640    /// a surface is illegal and will result in an invalid_size error.
641    ///
642    /// The width and height must be greater than or equal to zero. Using
643    /// strictly negative values for width and height will result in a
644    /// invalid_size error.
645    ///
646    /// # Arguments
647    ///
648    /// - `width`:
649    /// - `height`:
650    #[inline]
651    pub fn set_min_size(&self, width: i32, height: i32) {
652        let (arg0, arg1) = (width, height);
653        let mut args = [wl_argument { i: arg0 }, wl_argument { i: arg1 }];
654        // SAFETY: - self.proxy has the interface INTERFACE
655        //         - 8 < INTERFACE.method_count = 14
656        //         - the request signature is `ii`
657        unsafe {
658            self.proxy.send_request(8, &mut args);
659        }
660    }
661
662    /// maximize the window
663    ///
664    /// Maximize the surface.
665    ///
666    /// After requesting that the surface should be maximized, the compositor
667    /// will respond by emitting a configure event. Whether this configure
668    /// actually sets the window maximized is subject to compositor policies.
669    /// The client must then update its content, drawing in the configured
670    /// state. The client must also acknowledge the configure when committing
671    /// the new content (see ack_configure).
672    ///
673    /// It is up to the compositor to decide how and where to maximize the
674    /// surface, for example which output and what region of the screen should
675    /// be used.
676    ///
677    /// If the surface was already maximized, the compositor will still emit
678    /// a configure event with the "maximized" state.
679    ///
680    /// If the surface is in a fullscreen state, this request has no direct
681    /// effect. It may alter the state the surface is returned to when
682    /// unmaximized unless overridden by the compositor.
683    #[inline]
684    pub fn set_maximized(&self) {
685        let mut args = [];
686        // SAFETY: - self.proxy has the interface INTERFACE
687        //         - 9 < INTERFACE.method_count = 14
688        //         - the request signature is ``
689        unsafe {
690            self.proxy.send_request(9, &mut args);
691        }
692    }
693
694    /// unmaximize the window
695    ///
696    /// Unmaximize the surface.
697    ///
698    /// After requesting that the surface should be unmaximized, the compositor
699    /// will respond by emitting a configure event. Whether this actually
700    /// un-maximizes the window is subject to compositor policies.
701    /// If available and applicable, the compositor will include the window
702    /// geometry dimensions the window had prior to being maximized in the
703    /// configure event. The client must then update its content, drawing it in
704    /// the configured state. The client must also acknowledge the configure
705    /// when committing the new content (see ack_configure).
706    ///
707    /// It is up to the compositor to position the surface after it was
708    /// unmaximized; usually the position the surface had before maximizing, if
709    /// applicable.
710    ///
711    /// If the surface was already not maximized, the compositor will still
712    /// emit a configure event without the "maximized" state.
713    ///
714    /// If the surface is in a fullscreen state, this request has no direct
715    /// effect. It may alter the state the surface is returned to when
716    /// unmaximized unless overridden by the compositor.
717    #[inline]
718    pub fn unset_maximized(&self) {
719        let mut args = [];
720        // SAFETY: - self.proxy has the interface INTERFACE
721        //         - 10 < INTERFACE.method_count = 14
722        //         - the request signature is ``
723        unsafe {
724            self.proxy.send_request(10, &mut args);
725        }
726    }
727
728    /// set the window as fullscreen on an output
729    ///
730    /// Make the surface fullscreen.
731    ///
732    /// After requesting that the surface should be fullscreened, the
733    /// compositor will respond by emitting a configure event. Whether the
734    /// client is actually put into a fullscreen state is subject to compositor
735    /// policies. The client must also acknowledge the configure when
736    /// committing the new content (see ack_configure).
737    ///
738    /// The output passed by the request indicates the client's preference as
739    /// to which display it should be set fullscreen on. If this value is NULL,
740    /// it's up to the compositor to choose which display will be used to map
741    /// this surface.
742    ///
743    /// If the surface doesn't cover the whole output, the compositor will
744    /// position the surface in the center of the output and compensate with
745    /// with border fill covering the rest of the output. The content of the
746    /// border fill is undefined, but should be assumed to be in some way that
747    /// attempts to blend into the surrounding area (e.g. solid black).
748    ///
749    /// If the fullscreened surface is not opaque, the compositor must make
750    /// sure that other screen content not part of the same surface tree (made
751    /// up of subsurfaces, popups or similarly coupled surfaces) are not
752    /// visible below the fullscreened surface.
753    ///
754    /// # Arguments
755    ///
756    /// - `output`:
757    #[inline]
758    pub fn set_fullscreen(&self, output: Option<&WlOutputRef>) {
759        let (arg0,) = (output,);
760        let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
761        let obj0 = obj0_lock
762            .map(|obj0_lock| check_argument_proxy("output", obj0_lock.wl_proxy()))
763            .unwrap_or(ptr::null_mut());
764        let mut args = [wl_argument { o: obj0 }];
765        // SAFETY: - self.proxy has the interface INTERFACE
766        //         - 11 < INTERFACE.method_count = 14
767        //         - the request signature is `?o`
768        unsafe {
769            self.proxy.send_request(11, &mut args);
770        }
771    }
examples/poll-integration/../common/protocols/wayland/wl_surface.rs (line 429)
427    pub fn attach(&self, buffer: Option<&WlBufferRef>, x: i32, y: i32) {
428        let (arg0, arg1, arg2) = (buffer, x, y);
429        let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
430        let obj0 = obj0_lock
431            .map(|obj0_lock| check_argument_proxy("buffer", obj0_lock.wl_proxy()))
432            .unwrap_or(ptr::null_mut());
433        let mut args = [
434            wl_argument { o: obj0 },
435            wl_argument { i: arg1 },
436            wl_argument { i: arg2 },
437        ];
438        // SAFETY: - self.proxy has the interface INTERFACE
439        //         - 1 < INTERFACE.method_count = 11
440        //         - the request signature is `?oii`
441        unsafe {
442            self.proxy.send_request(1, &mut args);
443        }
444    }
445
446    /// mark part of the surface damaged
447    ///
448    /// This request is used to describe the regions where the pending
449    /// buffer is different from the current surface contents, and where
450    /// the surface therefore needs to be repainted. The compositor
451    /// ignores the parts of the damage that fall outside of the surface.
452    ///
453    /// Damage is double-buffered state, see wl_surface.commit.
454    ///
455    /// The damage rectangle is specified in surface-local coordinates,
456    /// where x and y specify the upper left corner of the damage rectangle.
457    ///
458    /// The initial value for pending damage is empty: no damage.
459    /// wl_surface.damage adds pending damage: the new pending damage
460    /// is the union of old pending damage and the given rectangle.
461    ///
462    /// wl_surface.commit assigns pending damage as the current damage,
463    /// and clears pending damage. The server will clear the current
464    /// damage as it repaints the surface.
465    ///
466    /// Note! New clients should not use this request. Instead damage can be
467    /// posted with wl_surface.damage_buffer which uses buffer coordinates
468    /// instead of surface coordinates.
469    ///
470    /// # Arguments
471    ///
472    /// - `x`: surface-local x coordinate
473    /// - `y`: surface-local y coordinate
474    /// - `width`: width of damage rectangle
475    /// - `height`: height of damage rectangle
476    #[inline]
477    pub fn damage(&self, x: i32, y: i32, width: i32, height: i32) {
478        let (arg0, arg1, arg2, arg3) = (x, y, width, height);
479        let mut args = [
480            wl_argument { i: arg0 },
481            wl_argument { i: arg1 },
482            wl_argument { i: arg2 },
483            wl_argument { i: arg3 },
484        ];
485        // SAFETY: - self.proxy has the interface INTERFACE
486        //         - 2 < INTERFACE.method_count = 11
487        //         - the request signature is `iiii`
488        unsafe {
489            self.proxy.send_request(2, &mut args);
490        }
491    }
492
493    /// request a frame throttling hint
494    ///
495    /// Request a notification when it is a good time to start drawing a new
496    /// frame, by creating a frame callback. This is useful for throttling
497    /// redrawing operations, and driving animations.
498    ///
499    /// When a client is animating on a wl_surface, it can use the 'frame'
500    /// request to get notified when it is a good time to draw and commit the
501    /// next frame of animation. If the client commits an update earlier than
502    /// that, it is likely that some updates will not make it to the display,
503    /// and the client is wasting resources by drawing too often.
504    ///
505    /// The frame request will take effect on the next wl_surface.commit.
506    /// The notification will only be posted for one frame unless
507    /// requested again. For a wl_surface, the notifications are posted in
508    /// the order the frame requests were committed.
509    ///
510    /// The server must send the notifications so that a client
511    /// will not send excessive updates, while still allowing
512    /// the highest possible update rate for clients that wait for the reply
513    /// before drawing again. The server should give some time for the client
514    /// to draw and commit after sending the frame callback events to let it
515    /// hit the next output refresh.
516    ///
517    /// A server should avoid signaling the frame callbacks if the
518    /// surface is not visible in any way, e.g. the surface is off-screen,
519    /// or completely obscured by other opaque surfaces.
520    ///
521    /// The object returned by this request will be destroyed by the
522    /// compositor after the callback is fired and as such the client must not
523    /// attempt to use it after that point.
524    ///
525    /// The callback_data passed in the callback is the current time, in
526    /// milliseconds, with an undefined base.
527    ///
528    /// # Arguments
529    ///
530    /// - `_queue`: The queue that the returned proxy is assigned to.
531    #[inline]
532    pub fn frame(&self, _queue: &Queue) -> WlCallback {
533        let mut args = [wl_argument { n: 0 }];
534        // SAFETY: - self.proxy has the interface INTERFACE
535        //         - 3 < INTERFACE.method_count = 11
536        //         - the request signature is `n`
537        //         - OwnedProxy::WL_INTERFACE is always a valid interface
538        let data = unsafe {
539            self.proxy
540                .send_constructor(_queue, 3, &mut args, WlCallback::WL_INTERFACE, None)
541        };
542        // SAFETY: data has the interface WlCallback::WL_INTERFACE
543        unsafe { proxy::low_level::from_untyped_owned(data) }
544    }
545
546    /// set opaque region
547    ///
548    /// This request sets the region of the surface that contains
549    /// opaque content.
550    ///
551    /// The opaque region is an optimization hint for the compositor
552    /// that lets it optimize the redrawing of content behind opaque
553    /// regions.  Setting an opaque region is not required for correct
554    /// behaviour, but marking transparent content as opaque will result
555    /// in repaint artifacts.
556    ///
557    /// The opaque region is specified in surface-local coordinates.
558    ///
559    /// The compositor ignores the parts of the opaque region that fall
560    /// outside of the surface.
561    ///
562    /// Opaque region is double-buffered state, see wl_surface.commit.
563    ///
564    /// wl_surface.set_opaque_region changes the pending opaque region.
565    /// wl_surface.commit copies the pending region to the current region.
566    /// Otherwise, the pending and current regions are never changed.
567    ///
568    /// The initial value for an opaque region is empty. Setting the pending
569    /// opaque region has copy semantics, and the wl_region object can be
570    /// destroyed immediately. A NULL wl_region causes the pending opaque
571    /// region to be set to empty.
572    ///
573    /// # Arguments
574    ///
575    /// - `region`: opaque region of the surface
576    #[inline]
577    pub fn set_opaque_region(&self, region: Option<&WlRegionRef>) {
578        let (arg0,) = (region,);
579        let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
580        let obj0 = obj0_lock
581            .map(|obj0_lock| check_argument_proxy("region", obj0_lock.wl_proxy()))
582            .unwrap_or(ptr::null_mut());
583        let mut args = [wl_argument { o: obj0 }];
584        // SAFETY: - self.proxy has the interface INTERFACE
585        //         - 4 < INTERFACE.method_count = 11
586        //         - the request signature is `?o`
587        unsafe {
588            self.proxy.send_request(4, &mut args);
589        }
590    }
591
592    /// set input region
593    ///
594    /// This request sets the region of the surface that can receive
595    /// pointer and touch events.
596    ///
597    /// Input events happening outside of this region will try the next
598    /// surface in the server surface stack. The compositor ignores the
599    /// parts of the input region that fall outside of the surface.
600    ///
601    /// The input region is specified in surface-local coordinates.
602    ///
603    /// Input region is double-buffered state, see wl_surface.commit.
604    ///
605    /// wl_surface.set_input_region changes the pending input region.
606    /// wl_surface.commit copies the pending region to the current region.
607    /// Otherwise the pending and current regions are never changed,
608    /// except cursor and icon surfaces are special cases, see
609    /// wl_pointer.set_cursor and wl_data_device.start_drag.
610    ///
611    /// The initial value for an input region is infinite. That means the
612    /// whole surface will accept input. Setting the pending input region
613    /// has copy semantics, and the wl_region object can be destroyed
614    /// immediately. A NULL wl_region causes the input region to be set
615    /// to infinite.
616    ///
617    /// # Arguments
618    ///
619    /// - `region`: input region of the surface
620    #[inline]
621    pub fn set_input_region(&self, region: Option<&WlRegionRef>) {
622        let (arg0,) = (region,);
623        let obj0_lock = arg0.map(|arg0| proxy::lock(arg0));
624        let obj0 = obj0_lock
625            .map(|obj0_lock| check_argument_proxy("region", obj0_lock.wl_proxy()))
626            .unwrap_or(ptr::null_mut());
627        let mut args = [wl_argument { o: obj0 }];
628        // SAFETY: - self.proxy has the interface INTERFACE
629        //         - 5 < INTERFACE.method_count = 11
630        //         - the request signature is `?o`
631        unsafe {
632            self.proxy.send_request(5, &mut args);
633        }
634    }