---
name: "wayland_subsurface_t"
section: "3"
platform: "linux"
package: "waylandpp-dev"
version: "1.0.0-6+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/wayland_subsurface_t"
---

# wayland\_subsurface\_t(3)

sub-surface interface to a wl\_surface

## NAME

wayland::subsurface\_t - sub-surface interface to a wl\_surface

## SYNOPSIS

`#include <wayland-client-protocol.hpp>`

Inherits **wayland::proxy\_t**.

### Public Types

enum class **wrapper\_type** { **standard**, **display**, **foreign**, **proxy\_wrapper** }\

### Public Member Functions

void **set\_position** (int32\_t x, int32\_t y)\
 reposition the sub-surface  void **place\_above** (**surface\_t** const &sibling)\
 restack the sub-surface  void **place\_below** (**surface\_t** const &sibling)\
 restack the sub-surface  void **set\_sync** ()\
 set sub-surface to synchronized mode  void **set\_desync** ()\
 set sub-surface to desynchronized mode  uint32\_t **get\_id** () const\
 Get the id of a proxy object.  std::string **get\_class** () const\
 Get the interface name (class) of a proxy object.  uint32\_t **get\_version** () const\
 Get the protocol object version of a proxy object.  **wrapper\_type** **get\_wrapper\_type** () const\
 Get the type of a proxy object.  void **set\_queue** (**event\_queue\_t** queue)\
 Assign a proxy to an event queue.  wl\_proxy \* **c\_ptr** () const\
 Get a pointer to the underlying C struct.  bool **proxy\_has\_object** () const\
 Check whether this wrapper actually wraps an object.  **operator bool** () const\
 Check whether this wrapper actually wraps an object.  bool **operator==** (const **proxy\_t** &right) const\
 Check whether two wrappers refer to the same object.  bool **operator!=** (const **proxy\_t** &right) const\
 Check whether two wrappers refer to different objects.  void **proxy\_release** ()\
 Release the wrapped object (if any), making this an empty wrapper.

### Static Public Attributes

static constexpr std::uint32\_t **set\_position\_since\_version** = 1\
 Minimum protocol version required for the **set\_position** function.  static constexpr std::uint32\_t **place\_above\_since\_version** = 1\
 Minimum protocol version required for the **place\_above** function.  static constexpr std::uint32\_t **place\_below\_since\_version** = 1\
 Minimum protocol version required for the **place\_below** function.  static constexpr std::uint32\_t **set\_sync\_since\_version** = 1\
 Minimum protocol version required for the **set\_sync** function.  static constexpr std::uint32\_t **set\_desync\_since\_version** = 1\
 Minimum protocol version required for the **set\_desync** function.

## Detailed Description

sub-surface interface to a wl\_surface

An additional interface to a wl\_surface object, which has been made a sub-surface. A sub-surface has one parent surface. A sub-surface's size and position are not limited to that of the parent. Particularly, a sub-surface is not automatically clipped to its parent's area.

A sub-surface becomes mapped, when a non-NULL wl\_buffer is applied and the parent surface is mapped. The order of which one happens first is irrelevant. A sub-surface is hidden if the parent becomes hidden, or if a NULL wl\_buffer is applied. These rules apply recursively through the tree of surfaces.

The behaviour of a wl\_surface.commit request on a sub-surface depends on the sub-surface's mode. The possible modes are synchronized and desynchronized, see methods wl\_subsurface.set\_sync and wl\_subsurface.set\_desync. Synchronized mode caches the wl\_surface state to be applied when the parent's state gets applied, and desynchronized mode applies the pending wl\_surface state directly. A sub-surface is initially in the synchronized mode.

Sub-surfaces also have another kind of state, which is managed by wl\_subsurface requests, as opposed to wl\_surface requests. This state includes the sub-surface position relative to the parent surface (wl\_subsurface.set\_position), and the stacking order of the parent and its sub-surfaces (wl\_subsurface.place\_above and .place\_below). This state is applied when the parent surface's wl\_surface state is applied, regardless of the sub-surface's mode. As the exception, set\_sync and set\_desync are effective immediately.

The main surface can be thought to be always in desynchronized mode, since it does not have a parent in the sub-surfaces sense.

Even if a sub-surface is in desynchronized mode, it will behave as in synchronized mode, if its parent surface behaves as in synchronized mode. This rule is applied recursively throughout the tree of surfaces. This means, that one can set a sub-surface into synchronized mode, and then assume that all its child and grand-child sub-surfaces are synchronized, too, without explicitly setting them.

If the wl\_surface associated with the wl\_subsurface is destroyed, the wl\_subsurface object becomes inert. Note, that destroying either object takes effect immediately. If you need to synchronize the removal of a sub-surface to the parent surface update, unmap the sub-surface first by attaching a NULL wl\_buffer, update parent, and then destroy the sub-surface.

If the parent wl\_surface object is destroyed, the sub-surface is unmapped.

Definition at line **3978** of file **wayland-client-protocol.hpp**.

## Member Enumeration Documentation

### enum class wayland::proxy\_t::wrapper\_type` [strong]`, ` [inherited]`

Underlying wl\_proxy type and properties of a **proxy\_t** that affect construction, destruction, and event handling

**Enumerator**

- *standard*

  *C pointer is a standard type compatible with wl\_proxy\*. Events are dispatched and it is destructed when the* **proxy\_t** *is destructed. User data is set.*

- *display*

  *C pointer is a wl\_display\*. No events are dispatched, wl\_display\_disconnect is called when the* **proxy\_t** *is destructed. User data is set.*

- *foreign*

  *C pointer is a standard type compatible with wl\_proxy\*, but another library owns it and it should not be touched in a way that could affect the operation of the other library. No events are dispatched, wl\_proxy\_destroy is not called when the* **proxy\_t** *is destructed, user data is not touched. Consequently, there is no reference counting for the* **proxy\_t***. Lifetime of such wrappers should preferably be short to minimize the chance that the owning library decides to destroy the wl\_proxy.*

- *proxy\_wrapper*

  *C pointer is a wl\_proxy\* that was constructed with wl\_proxy\_create\_wrapper. No events are dispatched, wl\_proxy\_wrapper\_destroy is called when the* **proxy\_t** *is destroyed. Reference counting is active. A reference to the* **proxy\_t** *creating this proxy wrapper is held to extend its lifetime until after the proxy wrapper is destroyed.*

*Definition at line* **116** *of file* **wayland-client.hpp***.*

## Member Function Documentation

### wl\_proxy \* wayland::proxy\_t::c\_ptr () const` [inherited]`

*Get a pointer to the underlying C struct.*

**Returns**

*The underlying wl\_proxy wrapped by this* **proxy\_t** *if it exists, otherwise an exception is thrown*

### std::string wayland::proxy\_t::get\_class () const` [inherited]`

*Get the interface name (class) of a proxy object.*

**Returns**

*The interface name of the object associated with the proxy*

### uint32\_t wayland::proxy\_t::get\_id () const` [inherited]`

*Get the id of a proxy object.*

**Returns**

*The id the object associated with the proxy*

### uint32\_t wayland::proxy\_t::get\_version () const` [inherited]`

*Get the protocol object version of a proxy object. Gets the protocol object version of a proxy object, or 0 if the proxy was created with unversioned API.*

*A returned value of 0 means that no version information is available, so the caller must make safe assumptions about the object's real version.*

**display\_t** *will always return version 0.*

**Returns**

*The protocol object version of the proxy or 0*

### wrapper\_type wayland::proxy\_t::get\_wrapper\_type () const` [inline]`, ` [inherited]`

*Get the type of a proxy object.*

*Definition at line* **302** *of file* **wayland-client.hpp***.*

### wayland::proxy\_t::operator bool () const` [inherited]`

*Check whether this wrapper actually wraps an object.*

**Returns**

*true if there is an underlying object, false if this wrapper is empty*

### bool wayland::proxy\_t::operator!= (const proxy\_t & right) const` [inherited]`

*Check whether two wrappers refer to different objects.*

### bool wayland::proxy\_t::operator== (const proxy\_t & right) const` [inherited]`

*Check whether two wrappers refer to the same object.*

### void subsurface\_t::place\_above (surface\_t const & sibling)

*restack the sub-surface*

**Parameters**

*sibling the reference surface*

*This sub-surface is taken from the stack, and put back just above the reference surface, changing the z-order of the sub-surfaces. The reference surface must be one of the sibling surfaces, or the parent surface. Using any other surface, including this sub-surface, will cause a protocol error.*

*The z-order is double-buffered. Requests are handled in order and applied immediately to a pending state. The final pending state is copied to the active state the next time the state of the parent surface is applied. When this happens depends on whether the parent surface is in synchronized mode or not. See wl\_subsurface.set\_sync and wl\_subsurface.set\_desync for details.*

*A new sub-surface is initially added as the top-most in the stack of its siblings and parent.*

*Definition at line* **3633** *of file* **wayland-client-protocol.cpp***.*

### void subsurface\_t::place\_below (surface\_t const & sibling)

*restack the sub-surface*

**Parameters**

*sibling the reference surface*

*The sub-surface is placed just below the reference surface. See wl\_subsurface.place\_above.*

*Definition at line* **3639** *of file* **wayland-client-protocol.cpp***.*

### bool wayland::proxy\_t::proxy\_has\_object () const` [inherited]`

*Check whether this wrapper actually wraps an object.*

**Returns**

*true if there is an underlying object, false if this wrapper is empty*

### void wayland::proxy\_t::proxy\_release ()` [inherited]`

*Release the wrapped object (if any), making this an empty wrapper. Note that* **display\_t** *instances cannot be released this way. Attempts to do so are ignored.*

**Examples** **foreign\_display.cpp***.*

### void subsurface\_t::set\_desync ()

*set sub-surface to desynchronized mode Change the commit behaviour of the sub-surface to desynchronized mode, also described as independent or freely running mode.*

*In desynchronized mode, wl\_surface.commit on a sub-surface will apply the pending state directly, without caching, as happens normally with a wl\_surface. Calling wl\_surface.commit on the parent surface has no effect on the sub-surface's wl\_surface state. This mode allows a sub-surface to be updated on its own.*

*If cached state exists when wl\_surface.commit is called in desynchronized mode, the pending state is added to the cached state, and applied as a whole. This invalidates the cache.*

*Note: even if a sub-surface is set to desynchronized, a parent sub-surface may override it to behave as synchronized. For details, see wl\_subsurface.*

*If a surface's parent surface behaves as desynchronized, then the cached state is applied on set\_desync.*

*Definition at line* **3651** *of file* **wayland-client-protocol.cpp***.*

### void subsurface\_t::set\_position (int32\_t x, int32\_t y)

*reposition the sub-surface*

**Parameters**

*x x coordinate in the parent surface* \
 *y y coordinate in the parent surface*

*This schedules a sub-surface position change. The sub-surface will be moved so that its origin (top left corner pixel) will be at the location x, y of the parent surface coordinate system. The coordinates are not restricted to the parent surface area. Negative values are allowed.*

*The scheduled coordinates will take effect whenever the state of the parent surface is applied. When this happens depends on whether the parent surface is in synchronized mode or not. See wl\_subsurface.set\_sync and wl\_subsurface.set\_desync for details.*

*If more than one set\_position request is invoked by the client before the commit of the parent surface, the position of a new request always replaces the scheduled position from any previous request.*

*The initial position is 0, 0.*

*Definition at line* **3627** *of file* **wayland-client-protocol.cpp***.*

### void wayland::proxy\_t::set\_queue (event\_queue\_t queue)` [inherited]`

*Assign a proxy to an event queue.*

**Parameters**

*queue The event queue that will handle this proxy*

*Assign proxy to event queue. Events coming from proxy will be queued in queue instead of the display's main queue.*

*See also:* **display\_t::dispatch\_queue()***.*

**Examples** **proxy\_wrapper.cpp***.*

### void subsurface\_t::set\_sync ()

*set sub-surface to synchronized mode Change the commit behaviour of the sub-surface to synchronized mode, also described as the parent dependent mode.*

*In synchronized mode, wl\_surface.commit on a sub-surface will accumulate the committed state in a cache, but the state will not be applied and hence will not change the compositor output. The cached state is applied to the sub-surface immediately after the parent surface's state is applied. This ensures atomic updates of the parent and all its synchronized sub-surfaces. Applying the cached state will invalidate the cache, so further parent surface commits do not (re-)apply old state.*

*See wl\_subsurface for the recursive effect of this mode.*

*Definition at line* **3645** *of file* **wayland-client-protocol.cpp***.*

## Member Data Documentation

### constexpr std::uint32\_t wayland::subsurface\_t::place\_above\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **place\_above** *function.*

*Definition at line* **4052** *of file* **wayland-client-protocol.hpp***.*

### constexpr std::uint32\_t wayland::subsurface\_t::place\_below\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **place\_below** *function.*

*Definition at line* **4065** *of file* **wayland-client-protocol.hpp***.*

### constexpr std::uint32\_t wayland::subsurface\_t::set\_desync\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_desync** *function.*

*Definition at line* **4117** *of file* **wayland-client-protocol.hpp***.*

### constexpr std::uint32\_t wayland::subsurface\_t::set\_position\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_position** *function.*

*Definition at line* **4026** *of file* **wayland-client-protocol.hpp***.*

### constexpr std::uint32\_t wayland::subsurface\_t::set\_sync\_since\_version = 1` [static]`, ` [constexpr]`

*Minimum protocol version required for the* **set\_sync** *function.*

*Definition at line* **4088** *of file* **wayland-client-protocol.hpp***.*

## Author

*Generated automatically by Doxygen for Wayland++ from the source code.*
