summaryrefslogtreecommitdiff
path: root/src/protocols/core/Subcompositor.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-08-03 17:58:06 +0200
committerVaxry <vaxry@vaxry.net>2024-08-03 17:58:06 +0200
commitae50f8614d92132d918663ea7551bd68eb13953a (patch)
tree566b716cbb4e3c56f2977c8c86dc73e6ccf50524 /src/protocols/core/Subcompositor.cpp
parent9f5a57ff4569db57372bd86bd48add85a3a1a5e4 (diff)
wayland/surface: fixup self-owning surface roles
fixes #7133
Diffstat (limited to 'src/protocols/core/Subcompositor.cpp')
-rw-r--r--src/protocols/core/Subcompositor.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/protocols/core/Subcompositor.cpp b/src/protocols/core/Subcompositor.cpp
index 90f89d91..2a7c06dc 100644
--- a/src/protocols/core/Subcompositor.cpp
+++ b/src/protocols/core/Subcompositor.cpp
@@ -119,7 +119,7 @@ Vector2D CWLSubsurfaceResource::posRelativeToParent() {
while (surf->role->role() == SURFACE_ROLE_SUBSURFACE &&
std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf);
- auto subsurface = (CWLSubsurfaceResource*)parent->role.get();
+ auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock();
pos += subsurface->position;
surf = subsurface->parent.lock();
}
@@ -130,10 +130,6 @@ bool CWLSubsurfaceResource::good() {
return resource->resource();
}
-eSurfaceRole CWLSubsurfaceResource::role() {
- return SURFACE_ROLE_SUBSURFACE;
-}
-
SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
SP<CWLSurfaceResource> surf = parent.lock();
std::vector<SP<CWLSurfaceResource>> surfacesVisited;
@@ -141,7 +137,7 @@ SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
while (surf->role->role() == SURFACE_ROLE_SUBSURFACE &&
std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf);
- auto subsurface = (CWLSubsurfaceResource*)parent->role.get();
+ auto subsurface = ((CSubsurfaceRole*)parent->role.get())->subsurface.lock();
surf = subsurface->parent.lock();
}
return surf;
@@ -171,7 +167,7 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
SP<CWLSurfaceResource> t1Parent = nullptr;
if (PARENT->role->role() == SURFACE_ROLE_SUBSURFACE) {
- auto subsurface = (CWLSubsurfaceResource*)PARENT->role.get();
+ auto subsurface = ((CSubsurfaceRole*)PARENT->role.get())->subsurface.lock();
t1Parent = subsurface->t1Parent();
} else
t1Parent = PARENT;
@@ -191,7 +187,7 @@ CWLSubcompositorResource::CWLSubcompositorResource(SP<CWlSubcompositor> resource
}
RESOURCE->self = RESOURCE;
- SURF->role = RESOURCE;
+ SURF->role = makeShared<CSubsurfaceRole>(RESOURCE);
PARENT->subsurfaces.emplace_back(RESOURCE);
LOGM(LOG, "New wl_subsurface with id {} at {:x}", id, (uintptr_t)RESOURCE.get());
@@ -225,3 +221,7 @@ void CWLSubcompositorProtocol::destroyResource(CWLSubcompositorResource* resourc
void CWLSubcompositorProtocol::destroyResource(CWLSubsurfaceResource* resource) {
std::erase_if(m_vSurfaces, [&](const auto& other) { return other.get() == resource; });
}
+
+CSubsurfaceRole::CSubsurfaceRole(SP<CWLSubsurfaceResource> sub) : subsurface(sub) {
+ ;
+}