diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index b5126b67..8f6d2cb5 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -1626,17 +1626,17 @@ PHLWINDOW CWindow::getSwallower() { if (!(*PSWALLOWREGEX).empty()) std::erase_if(candidates, [&](const auto& other) { return !RE2::FullMatch(other->m_szClass, *PSWALLOWREGEX); }); - if (candidates.size() <= 0) + if (candidates.size() == 0) return nullptr; if (!(*PSWALLOWEXREGEX).empty()) std::erase_if(candidates, [&](const auto& other) { return RE2::FullMatch(other->m_szTitle, *PSWALLOWEXREGEX); }); - if (candidates.size() <= 0) + if (candidates.size() == 0) return nullptr; if (candidates.size() == 1) - return candidates.at(0); + return candidates[0]; // walk up the focus history and find the last focused for (auto const& w : g_pCompositor->m_vWindowFocusHistory) { @@ -1648,7 +1648,7 @@ PHLWINDOW CWindow::getSwallower() { } // if none are found (??) then just return the first one - return candidates.at(0); + return candidates[0]; } void CWindow::unsetWindowData(eOverridePriority priority) { diff --git a/src/devices/IKeyboard.cpp b/src/devices/IKeyboard.cpp index 307d840b..89891ebd 100644 --- a/src/devices/IKeyboard.cpp +++ b/src/devices/IKeyboard.cpp @@ -126,14 +126,14 @@ void IKeyboard::setKeymap(const SStringRuleNames& rules) { updateModifiers(0, 0, modifiersState.locked, modifiersState.group); } - for (size_t i = 0; i < LEDNAMES.size(); ++i) { - ledIndexes.at(i) = xkb_map_led_get_index(xkbKeymap, LEDNAMES.at(i)); - Debug::log(LOG, "xkb: LED index {} (name {}) got index {}", i, LEDNAMES.at(i), ledIndexes.at(i)); + for (size_t i = 0; i < std::min(LEDNAMES.size(), ledIndexes.size()); ++i) { + ledIndexes[i] = xkb_map_led_get_index(xkbKeymap, LEDNAMES[i]); + Debug::log(LOG, "xkb: LED index {} (name {}) got index {}", i, LEDNAMES[i], ledIndexes[i]); } - for (size_t i = 0; i < MODNAMES.size(); ++i) { - modIndexes.at(i) = xkb_map_mod_get_index(xkbKeymap, MODNAMES.at(i)); - Debug::log(LOG, "xkb: Mod index {} (name {}) got index {}", i, MODNAMES.at(i), modIndexes.at(i)); + for (size_t i = 0; i < std::min(MODNAMES.size(), modIndexes.size()); ++i) { + modIndexes[i] = xkb_map_mod_get_index(xkbKeymap, MODNAMES[i]); + Debug::log(LOG, "xkb: Mod index {} (name {}) got index {}", i, MODNAMES[i], modIndexes[i]); } updateKeymapFD(); @@ -289,8 +289,8 @@ std::optional IKeyboard::getLEDs() { return {}; uint32_t leds = 0; - for (uint32_t i = 0; i < LED_COUNT; ++i) { - if (xkb_state_led_index_is_active(xkbState, ledIndexes.at(i))) + for (uint32_t i = 0; i < std::min((size_t)LED_COUNT, ledIndexes.size()); ++i) { + if (xkb_state_led_index_is_active(xkbState, ledIndexes[i])) leds |= (1 << i); } @@ -323,10 +323,10 @@ uint32_t IKeyboard::getModifiers() { uint32_t modMask = modifiersState.depressed | modifiersState.latched; uint32_t mods = 0; for (size_t i = 0; i < modIndexes.size(); ++i) { - if (modIndexes.at(i) == XKB_MOD_INVALID) + if (modIndexes[i] == XKB_MOD_INVALID) continue; - if (!(modMask & (1 << modIndexes.at(i)))) + if (!(modMask & (1 << modIndexes[i]))) continue; mods |= (1 << i); diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index 4773147f..dc301bfa 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -1357,7 +1357,7 @@ void CHyprMasterLayout::runOrientationCycle(SLayoutMessageHeader& header, CVarLi int nextOrPrev = 0; for (size_t i = 0; i < cycle.size(); ++i) { - if (PWORKSPACEDATA->orientation == cycle.at(i)) { + if (PWORKSPACEDATA->orientation == cycle[i]) { nextOrPrev = i + direction; break; } diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp index 48ef5e16..1c8e9976 100644 --- a/src/managers/PointerManager.cpp +++ b/src/managers/PointerManager.cpp @@ -475,7 +475,7 @@ SP CPointerManager::renderHWCursorBuffer(SP> CXCursorManager::loadStandardCursors(std::string cons // load the default xcursor shapes that exist in the theme for (size_t i = 0; i < XCURSOR_STANDARD_NAMES.size(); ++i) { - std::string shape{XCURSOR_STANDARD_NAMES.at(i)}; + std::string shape{XCURSOR_STANDARD_NAMES[i]}; auto xImages = XcursorShapeLoadImages(i << 1 /* wtf xcursor? */, name.c_str(), size); if (!xImages) { diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index 75a5eadb..3b641c36 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -402,14 +402,14 @@ std::optional> CHyprOpenGLImpl::getModsForFormat(EGLint fo result.reserve(mods.size()); bool linearIsExternal = false; - for (size_t i = 0; i < mods.size(); ++i) { - if (external.at(i)) { - if (mods.at(i) == DRM_FORMAT_MOD_LINEAR) + for (size_t i = 0; i < std::min(mods.size(), external.size()); ++i) { + if (external[i]) { + if (mods[i] == DRM_FORMAT_MOD_LINEAR) linearIsExternal = true; continue; } - result.push_back(mods.at(i)); + result.push_back(mods[i]); } // if the driver doesn't mark linear as external, add it. It's allowed unless the driver says otherwise. (e.g. nvidia) diff --git a/src/xwayland/XDataSource.cpp b/src/xwayland/XDataSource.cpp index e6282dcb..9384db69 100644 --- a/src/xwayland/XDataSource.cpp +++ b/src/xwayland/XDataSource.cpp @@ -57,8 +57,8 @@ void CXDataSource::send(const std::string& mime, CFileDescriptor fd) { mimeAtom = HYPRATOMS["UTF8_STRING"]; else { for (size_t i = 0; i < mimeTypes.size(); ++i) { - if (mimeTypes.at(i) == mime) { - mimeAtom = mimeAtoms.at(i); + if (mimeTypes[i] == mime) { + mimeAtom = mimeAtoms[i]; break; } } diff --git a/src/xwayland/XWM.cpp b/src/xwayland/XWM.cpp index 81900c7b..68552dd6 100644 --- a/src/xwayland/XWM.cpp +++ b/src/xwayland/XWM.cpp @@ -1051,13 +1051,13 @@ void CXWM::readWindowData(SP surf) { }; for (size_t i = 0; i < interestingProps.size(); i++) { - xcb_get_property_cookie_t cookie = xcb_get_property(connection, 0, surf->xID, interestingProps.at(i), XCB_ATOM_ANY, 0, 2048); + xcb_get_property_cookie_t cookie = xcb_get_property(connection, 0, surf->xID, interestingProps[i], XCB_ATOM_ANY, 0, 2048); xcb_get_property_reply_t* reply = xcb_get_property_reply(connection, cookie, nullptr); if (!reply) { Debug::log(ERR, "[xwm] Failed to get window property"); continue; } - readProp(surf, interestingProps.at(i), reply); + readProp(surf, interestingProps[i], reply); free(reply); } }