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) {
|
|
|
|
((IWaylandProtocol*)data)->onDisplayDestroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IWaylandProtocol::onDisplayDestroy() {
|
|
|
|
wl_global_destroy(m_pGlobal);
|
|
|
|
}
|
|
|
|
|
2024-04-22 19:44:25 +02:00
|
|
|
IWaylandProtocol::IWaylandProtocol(const wl_interface* iface, const int& ver, const std::string& name) : m_szName(name) {
|
2023-07-18 15:30:28 +02:00
|
|
|
m_pGlobal = wl_global_create(g_pCompositor->m_sWLDisplay, iface, ver, this, &bindManagerInternal);
|
|
|
|
|
|
|
|
if (!m_pGlobal) {
|
2024-04-22 19:44:25 +02:00
|
|
|
protoLog(ERR, "could not create a global");
|
2023-07-18 15:30:28 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_liDisplayDestroy.notify = displayDestroyInternal;
|
|
|
|
wl_display_add_destroy_listener(g_pCompositor->m_sWLDisplay, &m_liDisplayDestroy);
|
|
|
|
|
2024-04-22 19:44:25 +02:00
|
|
|
protoLog(LOG, "Registered global");
|
2023-07-18 15:30:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
IWaylandProtocol::~IWaylandProtocol() {
|
|
|
|
onDisplayDestroy();
|
|
|
|
}
|