---
name: "wayland_server_shm_pool_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_server_shm_pool_t"
---

# wayland\_server\_shm\_pool\_t(3)

a shared memory pool

## NAME

wayland::server::shm\_pool\_t - a shared memory pool

## SYNOPSIS

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

Inherits wayland::server::resource\_t.

### Public Member Functions

std::function\< void(**buffer\_t**, int32\_t, int32\_t, int32\_t, int32\_t, shm\_format)\> & **on\_create\_buffer** ()\
 create a buffer from the pool  std::function\< void()\> & **on\_destroy** ()\
 destroy the pool  std::function\< void(int32\_t)\> & **on\_resize** ()\
 change the size of the pool mapping  bool **proxy\_has\_object** () const\
 Check whether this wrapper actually wraps an object.  void **post\_no\_memory** () const\
 uint32\_t **get\_id** () const\
 client\_t **get\_client** () const\
 unsigned int **get\_version** () const\
 std::string **get\_class** ()\

## Detailed Description

a shared memory pool

The wl\_shm\_pool object encapsulates a piece of memory shared between the compositor and client. Through the wl\_shm\_pool object, the client can allocate shared memory wl\_buffer objects. All objects created through the same pool share the same underlying mapped memory. Reusing the mapped memory avoids the setup/teardown overhead and is useful when interactively resizing a surface or for many small buffers.

Definition at line **327** of file **wayland-server-protocol.hpp**.

## Member Function Documentation

### std::string wayland::server::resource\_t::get\_class ()` [inherited]`

Retrieve the interface name (class) of a resource object.

**Returns**

Interface name of the resource object.

### client\_t wayland::server::resource\_t::get\_client () const` [inherited]`

Get the associated client

**Returns**

the client that owns the resource.

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

Get the internal ID of the resource

**Returns**

the internal ID of the resource

### unsigned int wayland::server::resource\_t::get\_version () const` [inherited]`

Get interface version

**Returns**

Interface version this resource has been constructed with.

### std::function\< void(buffer\_t, int32\_t, int32\_t, int32\_t, int32\_t, shm\_format)\> & shm\_pool\_t::on\_create\_buffer ()

create a buffer from the pool

**Parameters**

*id* buffer to create \
 *offset* buffer byte offset within the pool \
 *width* buffer width, in pixels \
 *height* buffer height, in pixels \
 *stride* number of bytes from the beginning of one row to the beginning of the next row \
 *format* buffer pixel format

Create a wl\_buffer object from the pool.

The buffer is created offset bytes into the pool and has width and height as specified. The stride argument specifies the number of bytes from the beginning of one row to the beginning of the next. The format is the pixel format of the buffer and must be one of those advertised through the wl\_shm.format event.

A buffer will keep a reference to the pool it was created from so it is valid to destroy the pool immediately after creating a buffer from it.

Definition at line **1692** of file **wayland-server-protocol.cpp**.

### std::function\< void()\> & shm\_pool\_t::on\_destroy ()

destroy the pool Destroy the shared memory pool.

The mmapped memory will be released when all buffers that have been created from this pool are gone.

Definition at line **1698** of file **wayland-server-protocol.cpp**.

### std::function\< void(int32\_t)\> & shm\_pool\_t::on\_resize ()

change the size of the pool mapping

**Parameters**

*size* new size of the pool, in bytes

This request will cause the server to remap the backing memory for the pool from the file descriptor passed when the pool was created, but using the new size. This request can only be used to make the pool bigger.

```
This request only changes the amount of bytes that are mmapped
by the server and does not touch the file corresponding to the
file descriptor passed at creation time. It is the client's
responsibility to ensure that the file is at least as big as
the new pool size.
```

Definition at line **1704** of file **wayland-server-protocol.cpp**.

### void wayland::server::resource\_t::post\_no\_memory () const` [inherited]`

Post 'not enough memory' error to the client

If the compositor has not enough memory to fulfill a certail request of the client, this function can be called to notify the client of this circumstance.

### bool wayland::server::resource\_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

## Author

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