From b52a49b4c4c344784b3085cb93d3882d3ce9b4bb Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:16:35 +0100 Subject: tearing-control: hyprland impl (#5655) * tearing: hl impl * format --- src/protocols/WaylandProtocol.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/protocols/WaylandProtocol.cpp') diff --git a/src/protocols/WaylandProtocol.cpp b/src/protocols/WaylandProtocol.cpp index 4600126c..76f5eba0 100644 --- a/src/protocols/WaylandProtocol.cpp +++ b/src/protocols/WaylandProtocol.cpp @@ -31,7 +31,14 @@ void CWaylandResource::markDefunct() { Debug::log(TRACE, "[wl res {:x}] now defunct", (uintptr_t)m_pWLResource); m_bDefunct = true; + wl_resource_set_user_data(m_pWLResource, nullptr); + + // we call it here because we need defunct to be set to true. + // if this function destroys us, we can't call wl_resource_set_user_data or + // destroy the resource. + if (m_fOnDestroyHandler) + m_fOnDestroyHandler(this); } CWaylandResource::~CWaylandResource() { @@ -80,6 +87,10 @@ void* CWaylandResource::data() { return m_pData; } +void CWaylandResource::setOnDestroyHandler(std::function fn) { + m_fOnDestroyHandler = fn; +} + static void bindManagerInternal(wl_client* client, void* data, uint32_t ver, uint32_t id) { ((IWaylandProtocol*)data)->bindManager(client, data, ver, id); } -- cgit v1.2.3