wayland::server::shm_pool_t(3)

πŸ’– wayland::server::shm_pool_t β€” a shared memory pool πŸ’–

okay so bestie, you're in the Wayland++ manual (server-flavored) and this page is all about shm_pool_t, aka a shared memory pool. It's giving "one memory region, many buffers, zero drama." Let's get into it 🫢


✨ SYNOPSIS ✨

#include <wayland-server-protocol.hpp>

πŸŽ€ 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. that's it, that's the vibe ✨

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. literally main character memory management behavior, no cap πŸ”₯

Definition at line 328 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 πŸŽ€

std::function< void(buffer_t, int32_t, int32_t, int32_t, int32_t,
    shm_format)> & on_create_buffer ()

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. (yes, must β€” vibe check your formats, bestie πŸ’€)

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. so you can destroy the pool right away and it's still slay 🫢

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. so like, it's not gone-gone until the last buffer dips ✨

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. ⬆️ (bigger only, no shrinking bestie, that's the rule)

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 certain request of the client, this function can be called to notify the client of this circumstance. like, "sorry bestie, no memory rn" 😭


πŸ’œ 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. (not me writing this by hand, the robots ate and left no crumbs πŸ€–πŸ’…)


and that's the page!! πŸ¦‹ version 1.0.1, dated Fri Mar 27 2026 13:15 β€” mwah, go build something iconic, ily, bye πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from