kodi
Classes | Public Types | Public Member Functions | List of all members
KODI::WINDOWING::WAYLAND::CRegistry Class Reference

Handle Wayland globals. More...

#include <Registry.h>

Public Types

using AddHandler = std::function< void(std::uint32_t, wayland::proxy_t &&)>
 
using RemoveHandler = std::function< void(std::uint32_t) >
 

Public Member Functions

 CRegistry (CConnection &connection)
 
template<typename T >
void RequestSingleton (T &target, std::uint32_t minVersion, std::uint32_t maxVersion, bool required=true)
 Request a static singleton global to be bound to a proxy. More...
 
template<typename T >
void Request (std::uint32_t minVersion, std::uint32_t maxVersion, const AddHandler &addHandler, const RemoveHandler &removeHandler)
 Request a callback when a dynamic global appears or disappears. More...
 
void Bind ()
 Create a registry object at the compositor and do an roundtrip to bind objects. More...
 
void UnbindSingletons ()
 Unbind all singletons requested with RequestSingleton.
 

Detailed Description

Handle Wayland globals.

Request singletons (bound once) with RequestSingleton, non-singletons such as wl_output with Request, then call Bind once.

Make sure to destroy all registries before destroying the CConnection.

Member Function Documentation

◆ Bind()

void CRegistry::Bind ( )

Create a registry object at the compositor and do an roundtrip to bind objects.

This function blocks until the initial roundtrip is complete. All statically requested singletons that were available will be bound then.

Neither statically nor dynamically requested proxies will be bound before this function is called.

May throw std::runtime_error if a required global was not found.

Can only be called once for the same CRegistry object.

◆ Request()

template<typename T >
void KODI::WINDOWING::WAYLAND::CRegistry::Request ( std::uint32_t  minVersion,
std::uint32_t  maxVersion,
const AddHandler &  addHandler,
const RemoveHandler &  removeHandler 
)
inline

Request a callback when a dynamic global appears or disappears.

The callbacks may be called from the thread that calls Bind or the global Wayland message pump thread during Bind (but never at the same time) and only from the global thread after Bind returns.

Events that occur immediately upon binding are only delivered reliably if Bind is called from the Wayland message pump thread.

Cannot be called after Bind has been called.

Parameters
minVersionminimum version to bind
maxVersionmaximum version to bind
addHandlerfunction that is called when a global of the requested type is added
removeHandlerfunction that is called when a global of the requested type is removed

◆ RequestSingleton()

template<typename T >
void KODI::WINDOWING::WAYLAND::CRegistry::RequestSingleton ( T &  target,
std::uint32_t  minVersion,
std::uint32_t  maxVersion,
bool  required = true 
)
inline

Request a static singleton global to be bound to a proxy.

You should only use this if the singleton is announced at registry bind time (not dynamically) and you do not need to catch events that are sent immediately in response to the bind. Use Request in that case, even if there is ever only one instance of the object at maximum.

Cannot be called after Bind has been called.

Parameters
targettarget of waylandpp proxy type
minVersionminimum version to bind
maxVersionmaximum version to bind
requiredwhether to throw an exception when the bind cannot be satisfied by the compositor - exception is thrown in Bind

The documentation for this class was generated from the following files: