11 #include "Connection.h" 18 #include <wayland-client-protocol.hpp> 57 void RequestSingleton(T& target, std::uint32_t minVersion, std::uint32_t maxVersion,
bool required =
true)
59 RequestSingletonInternal(target, T::interface_name, minVersion, maxVersion, required);
61 using AddHandler = std::function<void(std::uint32_t , wayland::proxy_t&& )>;
62 using RemoveHandler = std::function<void(std::uint32_t) >;
84 std::uint32_t maxVersion,
85 const AddHandler& addHandler,
86 const RemoveHandler& removeHandler)
88 RequestInternal([]{
return T(); }, T::interface_name, minVersion, maxVersion, addHandler, removeHandler);
115 void RequestSingletonInternal(wayland::proxy_t& target, std::string
const& interfaceName, std::uint32_t minVersion, std::uint32_t maxVersion,
bool required);
116 void RequestInternal(std::function<wayland::proxy_t()> constructor, std::string
const& interfaceName, std::uint32_t minVersion, std::uint32_t maxVersion, AddHandler addHandler, RemoveHandler removeHandler);
117 void CheckRequired();
120 wayland::registry_t m_registry;
122 struct SingletonBindInfo
124 wayland::proxy_t& target;
126 std::uint32_t minVersion;
128 std::uint32_t maxVersion;
130 SingletonBindInfo(wayland::proxy_t& target, std::uint32_t minVersion, std::uint32_t maxVersion,
bool required)
131 : target{target}, minVersion{minVersion}, maxVersion{maxVersion}, required{required}
134 std::map<std::string, SingletonBindInfo> m_singletonBinds;
138 std::function<wayland::proxy_t()> constructor;
139 std::uint32_t minVersion;
140 std::uint32_t maxVersion;
141 AddHandler addHandler;
142 RemoveHandler removeHandler;
143 BindInfo(std::function<wayland::proxy_t()> constructor,
144 std::uint32_t minVersion,
145 std::uint32_t maxVersion,
146 AddHandler addHandler,
147 RemoveHandler removeHandler)
148 : constructor{std::move(constructor)},
149 minVersion{minVersion},
150 maxVersion{maxVersion},
151 addHandler{std::move(addHandler)},
152 removeHandler{std::move(removeHandler)}
155 std::map<std::string, BindInfo> m_binds;
157 std::map<std::uint32_t, std::reference_wrapper<BindInfo>> m_boundNames;
Handle Wayland globals.
Definition: Registry.h:35
Connection to Wayland compositor.
Definition: Connection.h:25
void Bind()
Create a registry object at the compositor and do an roundtrip to bind objects.
Definition: Registry.cpp:65
void UnbindSingletons()
Unbind all singletons requested with RequestSingleton.
Definition: Registry.cpp:147
Definition: AudioDecoder.h:18
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.
Definition: Registry.h:83
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.
Definition: Registry.h:57