2023-07-18 15:30:28 +02:00
|
|
|
#include "WaylandProtocol.hpp"
|
|
|
|
|
#include "../Compositor.hpp"
|
|
|
|
|
|
|
|
|
|
static void bindManagerInternal(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
|
|
|
|
((IWaylandProtocol*)data)->bindManager(client, data, ver, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void displayDestroyInternal(struct wl_listener* listener, void* data) {
|
2024-12-07 18:51:18 +01:00
|
|
|
SIWaylandProtocolDestroyWrapper* wrap = wl_container_of(listener, wrap, listener);
|
|
|
|
|
IWaylandProtocol* proto = wrap->parent;
|
2024-07-24 12:07:36 -05:00
|
|
|
proto->onDisplayDestroy();
|
2023-07-18 15:30:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void IWaylandProtocol::onDisplayDestroy() {
|
2024-07-29 19:19:47 +02:00
|
|
|
wl_list_remove(&m_liDisplayDestroy.listener.link);
|
|
|
|
|
wl_list_init(&m_liDisplayDestroy.listener.link);
|
2023-07-18 15:30:28 +02:00
|
|
|
wl_global_destroy(m_pGlobal);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-07 18:51:18 +01:00
|
|
|
IWaylandProtocol::IWaylandProtocol(const wl_interface* iface, const int& ver, const std::string& name) :
|
|
|
|
|
m_szName(name), m_pGlobal(wl_global_create(g_pCompositor->m_sWLDisplay, iface, ver, this, &bindManagerInternal)) {
|
2023-07-18 15:30:28 +02:00
|
|
|
|
2025-01-17 18:21:34 +01:00
|
|
|
if UNLIKELY (!m_pGlobal) {
|
2024-08-15 18:16:18 +02:00
|
|
|
LOGM(ERR, "could not create a global [{}]", m_szName);
|
2023-07-18 15:30:28 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-29 19:19:47 +02:00
|
|
|
wl_list_init(&m_liDisplayDestroy.listener.link);
|
|
|
|
|
m_liDisplayDestroy.listener.notify = displayDestroyInternal;
|
|
|
|
|
m_liDisplayDestroy.parent = this;
|
|
|
|
|
wl_display_add_destroy_listener(g_pCompositor->m_sWLDisplay, &m_liDisplayDestroy.listener);
|
2023-07-18 15:30:28 +02:00
|
|
|
|
2024-08-15 18:16:18 +02:00
|
|
|
LOGM(LOG, "Registered global [{}]", m_szName);
|
2023-07-18 15:30:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IWaylandProtocol::~IWaylandProtocol() {
|
|
|
|
|
onDisplayDestroy();
|
|
|
|
|
}
|
2024-06-08 10:07:59 +02:00
|
|
|
|
|
|
|
|
void IWaylandProtocol::removeGlobal() {
|
|
|
|
|
wl_global_remove(m_pGlobal);
|
|
|
|
|
}
|
2024-10-06 14:07:07 +01:00
|
|
|
|
|
|
|
|
wl_global* IWaylandProtocol::getGlobal() {
|
|
|
|
|
return m_pGlobal;
|
|
|
|
|
}
|