refactor: use std::ranges whenever possible (#10584)

This commit is contained in:
Kamikadze 2025-05-30 18:25:59 +05:00 committed by GitHub
parent 9bf1b49144
commit 9190443d95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 137 additions and 146 deletions

View file

@ -81,7 +81,7 @@ void CAlphaModifierProtocol::destroyAlphaModifier(CAlphaModifier* modifier) {
void CAlphaModifierProtocol::getSurface(CWpAlphaModifierV1* manager, uint32_t id, SP<CWLSurfaceResource> surface) {
CAlphaModifier* alphaModifier = nullptr;
auto iter = std::find_if(m_alphaModifiers.begin(), m_alphaModifiers.end(), [&](const auto& entry) { return entry.second->m_surface == surface; });
auto iter = std::ranges::find_if(m_alphaModifiers, [&](const auto& entry) { return entry.second->m_surface == surface; });
if (iter != m_alphaModifiers.end()) {
if (iter->second->m_resource) {

View file

@ -281,8 +281,8 @@ CColorManagementSurface::CColorManagementSurface(SP<CWpColorManagementSurfaceV1>
return;
}
const auto imageDescription = std::find_if(PROTO::colorManagement->m_imageDescriptions.begin(), PROTO::colorManagement->m_imageDescriptions.end(),
[&](const auto& other) { return other->resource()->resource() == image_description; });
const auto imageDescription =
std::ranges::find_if(PROTO::colorManagement->m_imageDescriptions, [&](const auto& other) { return other->resource()->resource() == image_description; });
if (imageDescription == PROTO::colorManagement->m_imageDescriptions.end()) {
r->error(WP_COLOR_MANAGEMENT_SURFACE_V1_ERROR_IMAGE_DESCRIPTION, "Image description not found");
return;

View file

@ -96,7 +96,7 @@ CDRMLeaseRequestResource::CDRMLeaseRequestResource(SP<CWpDrmLeaseRequestV1> reso
auto CONNECTOR = CDRMLeaseConnectorResource::fromResource(conn);
if (std::find(m_requested.begin(), m_requested.end(), CONNECTOR) != m_requested.end()) {
if (std::ranges::find(m_requested, CONNECTOR) != m_requested.end()) {
m_resource->error(WP_DRM_LEASE_REQUEST_V1_ERROR_DUPLICATE_CONNECTOR, "Connector already requested");
return;
}
@ -208,7 +208,7 @@ bool CDRMLeaseDeviceResource::good() {
}
void CDRMLeaseDeviceResource::sendConnector(PHLMONITOR monitor) {
if (std::find_if(m_connectorsSent.begin(), m_connectorsSent.end(), [monitor](const auto& e) { return e && !e->m_dead && e->m_monitor == monitor; }) != m_connectorsSent.end())
if (std::ranges::find_if(m_connectorsSent, [monitor](const auto& e) { return e && !e->m_dead && e->m_monitor == monitor; }) != m_connectorsSent.end())
return;
auto RESOURCE = makeShared<CDRMLeaseConnectorResource>(makeShared<CWpDrmLeaseConnectorV1>(m_resource->client(), m_resource->version(), 0), monitor);
@ -294,7 +294,7 @@ void CDRMLeaseProtocol::destroyResource(CDRMLeaseResource* resource) {
void CDRMLeaseProtocol::offer(PHLMONITOR monitor) {
std::erase_if(m_primaryDevice->m_offeredOutputs, [](const auto& e) { return e.expired(); });
if (std::find(m_primaryDevice->m_offeredOutputs.begin(), m_primaryDevice->m_offeredOutputs.end(), monitor) != m_primaryDevice->m_offeredOutputs.end())
if (std::ranges::find(m_primaryDevice->m_offeredOutputs, monitor) != m_primaryDevice->m_offeredOutputs.end())
return;
if (monitor->m_output->getBackend()->type() != Aquamarine::AQ_BACKEND_DRM)

View file

@ -78,7 +78,7 @@ std::vector<std::string> CWLRDataSource::mimes() {
}
void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) {
if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAskSend with non-existent mime");
return;
}
@ -87,7 +87,7 @@ void CWLRDataSource::send(const std::string& mime, CFileDescriptor fd) {
}
void CWLRDataSource::accepted(const std::string& mime) {
if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end())
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end())
LOGM(ERR, "Compositor/App bug: CWLRDataSource::sendAccepted with non-existent mime");
// wlr has no accepted
@ -315,7 +315,7 @@ void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary)
}
SP<CWLRDataDevice> CDataDeviceWLRProtocol::dataDeviceForClient(wl_client* c) {
auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; });
auto it = std::ranges::find_if(m_devices, [c](const auto& e) { return e->client() == c; });
if (it == m_devices.end())
return nullptr;
return *it;

View file

@ -36,7 +36,7 @@ bool CFocusGrab::good() {
}
bool CFocusGrab::isSurfaceComitted(SP<CWLSurfaceResource> surface) {
auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [surface](const auto& o) { return o.first == surface; });
auto iter = std::ranges::find_if(m_surfaces, [surface](const auto& o) { return o.first == surface; });
if (iter == m_surfaces.end())
return false;
@ -70,7 +70,7 @@ void CFocusGrab::finish(bool sendCleared) {
}
void CFocusGrab::addSurface(SP<CWLSurfaceResource> surface) {
auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [surface](const auto& e) { return e.first == surface; });
auto iter = std::ranges::find_if(m_surfaces, [surface](const auto& e) { return e.first == surface; });
if (iter == m_surfaces.end())
m_surfaces.emplace(surface, makeUnique<CFocusGrabSurfaceState>(this, surface));
}

View file

@ -69,7 +69,7 @@ void CForeignToplevelList::onMap(PHLWINDOW pWindow) {
SP<CForeignToplevelHandle> CForeignToplevelList::handleForWindow(PHLWINDOW pWindow) {
std::erase_if(m_handles, [](const auto& wp) { return wp.expired(); });
const auto IT = std::find_if(m_handles.begin(), m_handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; });
const auto IT = std::ranges::find_if(m_handles, [pWindow](const auto& h) { return h->window() == pWindow; });
return IT == m_handles.end() ? SP<CForeignToplevelHandle>{} : IT->lock();
}

View file

@ -247,7 +247,7 @@ void CForeignToplevelWlrManager::onMap(PHLWINDOW pWindow) {
SP<CForeignToplevelHandleWlr> CForeignToplevelWlrManager::handleForWindow(PHLWINDOW pWindow) {
std::erase_if(m_handles, [](const auto& wp) { return wp.expired(); });
const auto IT = std::find_if(m_handles.begin(), m_handles.end(), [pWindow](const auto& h) { return h->window() == pWindow; });
const auto IT = std::ranges::find_if(m_handles, [pWindow](const auto& h) { return h->window() == pWindow; });
return IT == m_handles.end() ? SP<CForeignToplevelHandleWlr>{} : IT->lock();
}

View file

@ -109,7 +109,7 @@ void CHyprlandSurfaceProtocol::destroySurface(CHyprlandSurface* surface) {
void CHyprlandSurfaceProtocol::getSurface(CHyprlandSurfaceManagerV1* manager, uint32_t id, SP<CWLSurfaceResource> surface) {
CHyprlandSurface* hyprlandSurface = nullptr;
auto iter = std::find_if(m_surfaces.begin(), m_surfaces.end(), [&](const auto& entry) { return entry.second->m_surface == surface; });
auto iter = std::ranges::find_if(m_surfaces, [&](const auto& entry) { return entry.second->m_surface == surface; });
if (iter != m_surfaces.end()) {
if (iter->second->m_resource) {

View file

@ -130,7 +130,7 @@ CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<C
});
m_resource->setAckConfigure([this](CZwlrLayerSurfaceV1* r, uint32_t serial) {
auto serialFound = std::find_if(m_serials.begin(), m_serials.end(), [serial](const auto& e) { return e.first == serial; });
auto serialFound = std::ranges::find_if(m_serials, [serial](const auto& e) { return e.first == serial; });
if (serialFound == m_serials.end()) {
r->error(ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE, "Serial invalid in ack_configure");

View file

@ -46,8 +46,7 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
});
} else {
// if it wasn't inserted then find its index in vec
auto it =
std::find_if(formatsVec.begin(), formatsVec.end(), [fmt, mod](const SDMABUFFormatTableEntry& oth) { return oth.fmt == fmt.drmFormat && oth.modifier == mod; });
auto it = std::ranges::find_if(formatsVec, [fmt, mod](const SDMABUFFormatTableEntry& oth) { return oth.fmt == fmt.drmFormat && oth.modifier == mod; });
m_rendererTranche.indicies.push_back(it - formatsVec.begin());
}
}
@ -69,8 +68,7 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
.modifier = mod,
});
} else {
auto it = std::find_if(formatsVec.begin(), formatsVec.end(),
[fmt, mod](const SDMABUFFormatTableEntry& oth) { return oth.fmt == fmt.drmFormat && oth.modifier == mod; });
auto it = std::ranges::find_if(formatsVec, [fmt, mod](const SDMABUFFormatTableEntry& oth) { return oth.fmt == fmt.drmFormat && oth.modifier == mod; });
tranche.indicies.push_back(it - formatsVec.begin());
}
}
@ -89,7 +87,7 @@ CDMABUFFormatTable::CDMABUFFormatTable(SDMABUFTranche _rendererTranche, std::vec
return;
}
std::copy(formatsVec.begin(), formatsVec.end(), arr);
std::ranges::copy(formatsVec, arr);
munmap(arr, m_tableSize);
@ -169,7 +167,7 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP<CZwpLinuxBufferParamsV
m_attrs->size = {w, h};
m_attrs->format = fmt;
m_attrs->planes = 4 - std::count(m_attrs->fds.begin(), m_attrs->fds.end(), -1);
m_attrs->planes = 4 - std::ranges::count(m_attrs->fds, -1);
create(0);
});
@ -188,7 +186,7 @@ CLinuxDMABUFParamsResource::CLinuxDMABUFParamsResource(SP<CZwpLinuxBufferParamsV
m_attrs->size = {w, h};
m_attrs->format = fmt;
m_attrs->planes = 4 - std::count(m_attrs->fds.begin(), m_attrs->fds.end(), -1);
m_attrs->planes = 4 - std::ranges::count(m_attrs->fds, -1);
create(id);
});
@ -564,8 +562,8 @@ void CLinuxDMABufV1Protocol::updateScanoutTranche(SP<CWLSurfaceResource> surface
return;
}
const auto& monitorTranchePair = std::find_if(m_formatTable->m_monitorTranches.begin(), m_formatTable->m_monitorTranches.end(),
[pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; });
const auto& monitorTranchePair =
std::ranges::find_if(m_formatTable->m_monitorTranches, [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; });
if (monitorTranchePair == m_formatTable->m_monitorTranches.end()) {
LOGM(LOG, "updateScanoutTranche: monitor has no tranche");

View file

@ -229,7 +229,7 @@ void CPointerConstraintsProtocol::onNewConstraint(SP<CPointerConstraint> constra
const auto OWNER = constraint->owner();
const auto DUPES = std::count_if(m_constraints.begin(), m_constraints.end(), [OWNER](const auto& c) { return c->owner() == OWNER; });
const auto DUPES = std::ranges::count_if(m_constraints, [OWNER](const auto& c) { return c->owner() == OWNER; });
if UNLIKELY (DUPES > 1) {
LOGM(ERR, "Constraint for surface duped");

View file

@ -79,7 +79,7 @@ std::vector<std::string> CPrimarySelectionSource::mimes() {
}
void CPrimarySelectionSource::send(const std::string& mime, CFileDescriptor fd) {
if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CPrimarySelectionSource::sendAskSend with non-existent mime");
return;
}
@ -88,7 +88,7 @@ void CPrimarySelectionSource::send(const std::string& mime, CFileDescriptor fd)
}
void CPrimarySelectionSource::accepted(const std::string& mime) {
if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end())
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end())
LOGM(ERR, "Compositor/App bug: CPrimarySelectionSource::sendAccepted with non-existent mime");
// primary sel has no accepted
@ -327,7 +327,7 @@ void CPrimarySelectionProtocol::onPointerFocus() {
}
SP<CPrimarySelectionDevice> CPrimarySelectionProtocol::dataDeviceForClient(wl_client* c) {
auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; });
auto it = std::ranges::find_if(m_devices, [c](const auto& e) { return e->client() == c; });
if (it == m_devices.end())
return nullptr;
return *it;

View file

@ -214,5 +214,5 @@ void CSecurityContextProtocol::destroyContext(CSecurityContext* context) {
}
bool CSecurityContextProtocol::isClientSandboxed(const wl_client* client) {
return std::find_if(m_sandboxedClients.begin(), m_sandboxedClients.end(), [client](const auto& e) { return e->m_client == client; }) != m_sandboxedClients.end();
return std::ranges::find_if(m_sandboxedClients, [client](const auto& e) { return e->m_client == client; }) != m_sandboxedClients.end();
}

View file

@ -31,7 +31,7 @@ CVirtualKeyboardV1Resource::CVirtualKeyboardV1Resource(SP<CZwpVirtualKeyboardV1>
.state = (wl_keyboard_key_state)state,
});
const bool CONTAINS = std::find(m_pressed.begin(), m_pressed.end(), key) != m_pressed.end();
const bool CONTAINS = std::ranges::find(m_pressed, key) != m_pressed.end();
if (state && !CONTAINS)
m_pressed.emplace_back(key);
else if (!state && CONTAINS)

View file

@ -33,8 +33,7 @@ CXDGActivationToken::CXDGActivationToken(SP<CXdgActivationTokenV1> resource_) :
PROTO::activation->m_sentTokens.push_back({m_token, m_resource->client()});
auto count = std::count_if(PROTO::activation->m_sentTokens.begin(), PROTO::activation->m_sentTokens.end(),
[this](const auto& other) { return other.client == m_resource->client(); });
auto count = std::ranges::count_if(PROTO::activation->m_sentTokens, [this](const auto& other) { return other.client == m_resource->client(); });
if UNLIKELY (count > 10) {
// remove first token. Too many, dear app.
@ -68,7 +67,7 @@ void CXDGActivationProtocol::bindManager(wl_client* client, void* data, uint32_t
RESOURCE->setDestroy([this](CXdgActivationV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
RESOURCE->setGetActivationToken([this](CXdgActivationV1* pMgr, uint32_t id) { this->onGetToken(pMgr, id); });
RESOURCE->setActivate([this](CXdgActivationV1* pMgr, const char* token, wl_resource* surface) {
auto TOKEN = std::find_if(m_sentTokens.begin(), m_sentTokens.end(), [token](const auto& t) { return t.token == token; });
auto TOKEN = std::ranges::find_if(m_sentTokens, [token](const auto& t) { return t.token == token; });
if UNLIKELY (TOKEN == m_sentTokens.end()) {
LOGM(WARN, "activate event for non-existent token {}??", token);

View file

@ -258,7 +258,7 @@ uint32_t CXDGToplevelResource::setSize(const Vector2D& size) {
}
uint32_t CXDGToplevelResource::setMaximized(bool maximized) {
bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_MAXIMIZED) != m_pendingApply.states.end();
bool set = std::ranges::find(m_pendingApply.states, XDG_TOPLEVEL_STATE_MAXIMIZED) != m_pendingApply.states.end();
if (maximized == set)
return m_owner->m_scheduledSerial;
@ -272,7 +272,7 @@ uint32_t CXDGToplevelResource::setMaximized(bool maximized) {
}
uint32_t CXDGToplevelResource::setFullscreen(bool fullscreen) {
bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_FULLSCREEN) != m_pendingApply.states.end();
bool set = std::ranges::find(m_pendingApply.states, XDG_TOPLEVEL_STATE_FULLSCREEN) != m_pendingApply.states.end();
if (fullscreen == set)
return m_owner->m_scheduledSerial;
@ -286,7 +286,7 @@ uint32_t CXDGToplevelResource::setFullscreen(bool fullscreen) {
}
uint32_t CXDGToplevelResource::setActive(bool active) {
bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_ACTIVATED) != m_pendingApply.states.end();
bool set = std::ranges::find(m_pendingApply.states, XDG_TOPLEVEL_STATE_ACTIVATED) != m_pendingApply.states.end();
if (active == set)
return m_owner->m_scheduledSerial;
@ -303,7 +303,7 @@ uint32_t CXDGToplevelResource::setSuspeneded(bool sus) {
if (m_resource->version() < 6)
return m_owner->scheduleConfigure(); // SUSPENDED is since 6
bool set = std::find(m_pendingApply.states.begin(), m_pendingApply.states.end(), XDG_TOPLEVEL_STATE_SUSPENDED) != m_pendingApply.states.end();
bool set = std::ranges::find(m_pendingApply.states, XDG_TOPLEVEL_STATE_SUSPENDED) != m_pendingApply.states.end();
if (sus == set)
return m_owner->m_scheduledSerial;

View file

@ -237,8 +237,8 @@ CXXColorManagementSurface::CXXColorManagementSurface(SP<CXxColorManagementSurfac
return;
}
const auto imageDescription = std::find_if(PROTO::xxColorManagement->m_imageDescriptions.begin(), PROTO::xxColorManagement->m_imageDescriptions.end(),
[&](const auto& other) { return other->resource()->resource() == image_description; });
const auto imageDescription =
std::ranges::find_if(PROTO::xxColorManagement->m_imageDescriptions, [&](const auto& other) { return other->resource()->resource() == image_description; });
if (imageDescription == PROTO::xxColorManagement->m_imageDescriptions.end()) {
r->error(XX_COLOR_MANAGEMENT_SURFACE_V4_ERROR_IMAGE_DESCRIPTION, "Image description not found");
return;

View file

@ -268,7 +268,7 @@ wl_client* CWLSurfaceResource::client() {
}
void CWLSurfaceResource::enter(PHLMONITOR monitor) {
if (std::find(m_enteredOutputs.begin(), m_enteredOutputs.end(), monitor) != m_enteredOutputs.end())
if (std::ranges::find(m_enteredOutputs, monitor) != m_enteredOutputs.end())
return;
if UNLIKELY (!PROTO::outputs.contains(monitor->m_name)) {
@ -295,7 +295,7 @@ void CWLSurfaceResource::enter(PHLMONITOR monitor) {
}
void CWLSurfaceResource::leave(PHLMONITOR monitor) {
if UNLIKELY (std::find(m_enteredOutputs.begin(), m_enteredOutputs.end(), monitor) == m_enteredOutputs.end())
if UNLIKELY (std::ranges::find(m_enteredOutputs, monitor) == m_enteredOutputs.end())
return;
auto output = PROTO::outputs.at(monitor->m_name)->outputResourceFrom(m_client);

View file

@ -171,7 +171,7 @@ void CWLDataSourceResource::accepted(const std::string& mime) {
return;
}
if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CWLDataSourceResource::sendAccepted with non-existent mime");
return;
}
@ -184,7 +184,7 @@ std::vector<std::string> CWLDataSourceResource::mimes() {
}
void CWLDataSourceResource::send(const std::string& mime, CFileDescriptor fd) {
if (std::find(m_mimeTypes.begin(), m_mimeTypes.end(), mime) == m_mimeTypes.end()) {
if (std::ranges::find(m_mimeTypes, mime) == m_mimeTypes.end()) {
LOGM(ERR, "Compositor/App bug: CWLDataSourceResource::sendAskSend with non-existent mime");
return;
}
@ -424,7 +424,7 @@ SP<IDataDevice> CWLDataDeviceProtocol::dataDeviceForClient(wl_client* c) {
return g_pXWayland->m_wm->getDataDevice();
#endif
auto it = std::find_if(m_devices.begin(), m_devices.end(), [c](const auto& e) { return e->client() == c; });
auto it = std::ranges::find_if(m_devices, [c](const auto& e) { return e->client() == c; });
if (it == m_devices.end())
return nullptr;
return *it;

View file

@ -204,10 +204,10 @@ void CWLPointerResource::sendButton(uint32_t timeMs, uint32_t button, wl_pointer
if (!(PROTO::seat->m_currentCaps & eHIDCapabilityType::HID_INPUT_CAPABILITY_POINTER))
return;
if (state == WL_POINTER_BUTTON_STATE_RELEASED && std::find(m_pressedButtons.begin(), m_pressedButtons.end(), button) == m_pressedButtons.end()) {
if (state == WL_POINTER_BUTTON_STATE_RELEASED && std::ranges::find(m_pressedButtons, button) == m_pressedButtons.end()) {
LOGM(ERR, "sendButton release on a non-pressed button");
return;
} else if (state == WL_POINTER_BUTTON_STATE_PRESSED && std::find(m_pressedButtons.begin(), m_pressedButtons.end(), button) != m_pressedButtons.end()) {
} else if (state == WL_POINTER_BUTTON_STATE_PRESSED && std::ranges::find(m_pressedButtons, button) != m_pressedButtons.end()) {
LOGM(ERR, "sendButton press on a non-pressed button");
return;
}

View file

@ -137,7 +137,7 @@ CWLSHMPoolResource::CWLSHMPoolResource(SP<CWlShmPool> resource_, CFileDescriptor
return;
}
if UNLIKELY (std::find(PROTO::shm->m_shmFormats.begin(), PROTO::shm->m_shmFormats.end(), fmt) == PROTO::shm->m_shmFormats.end()) {
if UNLIKELY (std::ranges::find(PROTO::shm->m_shmFormats, fmt) == PROTO::shm->m_shmFormats.end()) {
r->error(WL_SHM_ERROR_INVALID_FORMAT, "Format invalid");
return;
}

View file

@ -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();