summaryrefslogtreecommitdiff
path: root/src/protocols/WaylandProtocol.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-08-21 19:36:09 +0200
committerGitHub <noreply@github.com>2023-08-21 19:36:09 +0200
commit37128bfd43a3d86d270c09e34f18fe4df48c6b35 (patch)
treeade4b361562543679b7eaecbe27b5cd0415eef73 /src/protocols/WaylandProtocol.hpp
parent17d8e4750bd79e0d18b5d0c9f578f23fa47552f4 (diff)
internal: Wayland Protocol impl improvements (#2944)
Diffstat (limited to 'src/protocols/WaylandProtocol.hpp')
-rw-r--r--src/protocols/WaylandProtocol.hpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/protocols/WaylandProtocol.hpp b/src/protocols/WaylandProtocol.hpp
index 904a3053..a87bd519 100644
--- a/src/protocols/WaylandProtocol.hpp
+++ b/src/protocols/WaylandProtocol.hpp
@@ -2,22 +2,34 @@
#include "../defines.hpp"
+#define RESOURCE_OR_BAIL(resname) \
+ const auto resname = (CWaylandResource*)wl_resource_get_user_data(resource); \
+ if (!resname) \
+ return;
+
class CWaylandResource {
public:
- CWaylandResource(wl_client* client, const wl_interface* wlInterface, uint32_t version, uint32_t id, bool destroyInDestructor = false);
+ CWaylandResource(wl_client* client, const wl_interface* wlInterface, uint32_t version, uint32_t id);
~CWaylandResource();
bool good();
wl_resource* resource();
uint32_t version();
- void setImplementation(const void* impl, void* data, wl_resource_destroy_func_t df);
+ void setImplementation(const void* impl, wl_resource_destroy_func_t df);
+
+ wl_listener m_liResourceDestroy; // private but has to be public
+ void markDefunct();
+
+ void* data();
+ void setData(void* data);
private:
- bool m_bDestroyInDestructor = false;
- bool m_bImplementationSet = false;
- wl_client* m_pWLClient = nullptr;
- wl_resource* m_pWLResource = nullptr;
+ bool m_bImplementationSet = false;
+ bool m_bDefunct = false; // m_liResourceDestroy fired
+ wl_client* m_pWLClient = nullptr;
+ wl_resource* m_pWLResource = nullptr;
+ void* m_pData = nullptr;
};
class IWaylandProtocol {