summaryrefslogtreecommitdiff
path: root/src/protocols/IdleInhibit.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-06-08 10:07:59 +0200
committerGitHub <noreply@github.com>2024-06-08 10:07:59 +0200
commit6967a31450441fc5605c05db6f65505dace4b263 (patch)
tree255a3cff7f3e2eb8a50c952eab9b270a7937561d /src/protocols/IdleInhibit.cpp
parentc31d9ef4172452f6f219f91d9b87a24d91f0cf3a (diff)
wayland/core: move to new impl (#6268)
* wayland/core/dmabuf: move to new impl it's the final countdown
Diffstat (limited to 'src/protocols/IdleInhibit.cpp')
-rw-r--r--src/protocols/IdleInhibit.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/protocols/IdleInhibit.cpp b/src/protocols/IdleInhibit.cpp
index 0ff11a56..89eb3108 100644
--- a/src/protocols/IdleInhibit.cpp
+++ b/src/protocols/IdleInhibit.cpp
@@ -1,26 +1,23 @@
#include "IdleInhibit.hpp"
+#include "core/Compositor.hpp"
-CIdleInhibitor::CIdleInhibitor(SP<CIdleInhibitorResource> resource_, wlr_surface* surf_) : resource(resource_), surface(surf_) {
+CIdleInhibitor::CIdleInhibitor(SP<CIdleInhibitorResource> resource_, SP<CWLSurfaceResource> surf_) : resource(resource_), surface(surf_) {
;
}
-CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, wlr_surface* surface_) : resource(resource_), surface(surface_) {
- hyprListener_surfaceDestroy.initCallback(
- &surface->events.destroy,
- [this](void* owner, void* data) {
- surface = nullptr;
- hyprListener_surfaceDestroy.removeCallback();
- destroySent = true;
- events.destroy.emit();
- },
- this, "CIdleInhibitorResource");
+CIdleInhibitorResource::CIdleInhibitorResource(SP<CZwpIdleInhibitorV1> resource_, SP<CWLSurfaceResource> surface_) : resource(resource_), surface(surface_) {
+ listeners.destroySurface = surface->events.destroy.registerListener([this](std::any d) {
+ surface.reset();
+ listeners.destroySurface.reset();
+ destroySent = true;
+ events.destroy.emit();
+ });
resource->setOnDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); });
resource->setDestroy([this](CZwpIdleInhibitorV1* p) { PROTO::idleInhibit->removeInhibitor(this); });
}
CIdleInhibitorResource::~CIdleInhibitorResource() {
- hyprListener_surfaceDestroy.removeCallback();
if (!destroySent)
events.destroy.emit();
}
@@ -39,14 +36,14 @@ void CIdleInhibitProtocol::bindManager(wl_client* client, void* data, uint32_t v
RESOURCE->setDestroy([this](CZwpIdleInhibitManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
RESOURCE->setCreateInhibitor(
- [this](CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wl_resource* surface) { this->onCreateInhibitor(pMgr, id, wlr_surface_from_resource(surface)); });
+ [this](CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wl_resource* surface) { this->onCreateInhibitor(pMgr, id, CWLSurfaceResource::fromResource(surface)); });
}
void CIdleInhibitProtocol::removeInhibitor(CIdleInhibitorResource* resource) {
std::erase_if(m_vInhibitors, [resource](const auto& el) { return el.get() == resource; });
}
-void CIdleInhibitProtocol::onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, wlr_surface* surface) {
+void CIdleInhibitProtocol::onCreateInhibitor(CZwpIdleInhibitManagerV1* pMgr, uint32_t id, SP<CWLSurfaceResource> surface) {
const auto CLIENT = pMgr->client();
const auto RESOURCE = m_vInhibitors.emplace_back(makeShared<CIdleInhibitorResource>(makeShared<CZwpIdleInhibitorV1>(CLIENT, pMgr->version(), id), surface));