summaryrefslogtreecommitdiff
path: root/src/protocols/core/Subcompositor.cpp
diff options
context:
space:
mode:
authorKamikadze <40305144+Kam1k4dze@users.noreply.github.com>2025-05-30 18:25:59 +0500
committerGitHub <noreply@github.com>2025-05-30 14:25:59 +0100
commit9190443d951c21ab24201d033accf90b4d172f46 (patch)
tree28a5e4a1fa9c7424733ac7065a71cead7e141b6f /src/protocols/core/Subcompositor.cpp
parent9bf1b491440eac6f9c0d6853013ad5666c12d1d9 (diff)
refactor: use std::ranges whenever possible (#10584)
Diffstat (limited to 'src/protocols/core/Subcompositor.cpp')
-rw-r--r--src/protocols/core/Subcompositor.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/protocols/core/Subcompositor.cpp b/src/protocols/core/Subcompositor.cpp
index 4111b5dc..85a0edc4 100644
--- a/src/protocols/core/Subcompositor.cpp
+++ b/src/protocols/core/Subcompositor.cpp
@@ -30,7 +30,7 @@ CWLSubsurfaceResource::CWLSubsurfaceResource(SP<CWlSubsurface> resource_, SP<CWL
std::erase_if(m_parent->m_subsurfaces, [this](const auto& e) { return e == m_self || !e; });
- auto it = std::find(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), SURF);
+ auto it = std::ranges::find(m_parent->m_subsurfaces, SURF);
if (it == m_parent->m_subsurfaces.end()) {
LOGM(ERR, "Invalid surface reference in placeAbove, likely parent");
@@ -43,7 +43,7 @@ CWLSubsurfaceResource::CWLSubsurfaceResource(SP<CWlSubsurface> resource_, SP<CWL
m_parent->m_subsurfaces.emplace_back(m_self);
}
- std::sort(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), [](const auto& a, const auto& b) { return a->m_zIndex < b->m_zIndex; });
+ std::ranges::sort(m_parent->m_subsurfaces, [](const auto& a, const auto& b) { return a->m_zIndex < b->m_zIndex; });
});
m_resource->setPlaceBelow([this](CWlSubsurface* r, wl_resource* surf) {
@@ -61,7 +61,7 @@ CWLSubsurfaceResource::CWLSubsurfaceResource(SP<CWlSubsurface> resource_, SP<CWL
std::erase_if(m_parent->m_subsurfaces, [this](const auto& e) { return e == m_self || !e; });
- auto it = std::find(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), SURF);
+ auto it = std::ranges::find(m_parent->m_subsurfaces, SURF);
if (it == m_parent->m_subsurfaces.end()) {
LOGM(ERR, "Invalid surface reference in placeBelow, likely parent");
@@ -74,7 +74,7 @@ CWLSubsurfaceResource::CWLSubsurfaceResource(SP<CWlSubsurface> resource_, SP<CWL
m_parent->m_subsurfaces.emplace_back(m_self);
}
- std::sort(m_parent->m_subsurfaces.begin(), m_parent->m_subsurfaces.end(), [](const auto& a, const auto& b) { return a->m_zIndex < b->m_zIndex; });
+ std::ranges::sort(m_parent->m_subsurfaces, [](const auto& a, const auto& b) { return a->m_zIndex < b->m_zIndex; });
});
m_listeners.commitSurface = m_surface->m_events.commit.registerListener([this](std::any d) {
@@ -116,8 +116,7 @@ Vector2D CWLSubsurfaceResource::posRelativeToParent() {
// surfaces we've visited and if we hit a surface we've visited we bail out.
std::vector<SP<CWLSurfaceResource>> surfacesVisited;
- while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE &&
- std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
+ while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock();
pos += subsurface->m_position;
@@ -134,8 +133,7 @@ SP<CWLSurfaceResource> CWLSubsurfaceResource::t1Parent() {
SP<CWLSurfaceResource> surf = m_parent.lock();
std::vector<SP<CWLSurfaceResource>> surfacesVisited;
- while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE &&
- std::find_if(surfacesVisited.begin(), surfacesVisited.end(), [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
+ while (surf->m_role->role() == SURFACE_ROLE_SUBSURFACE && std::ranges::find_if(surfacesVisited, [surf](const auto& other) { return surf == other; }) == surfacesVisited.end()) {
surfacesVisited.emplace_back(surf);
auto subsurface = ((CSubsurfaceRole*)m_parent->m_role.get())->m_subsurface.lock();
surf = subsurface->m_parent.lock();