From a5234f26e4b7146ae7c2df25950f0177534cd643 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 16 Dec 2024 15:58:19 +0000 Subject: core: drop using deques in favor of vectors No point in most of these. --- hyprctl/main.cpp | 7 +-- src/Compositor.cpp | 6 +- src/Compositor.hpp | 1 - src/config/ConfigManager.cpp | 66 +++++++++++----------- src/config/ConfigManager.hpp | 19 +++---- src/debug/HyprDebugOverlay.cpp | 36 +++++++++++- src/debug/HyprDebugOverlay.hpp | 2 +- src/debug/HyprNotificationOverlay.cpp | 18 +++--- src/debug/HyprNotificationOverlay.hpp | 18 +++--- src/desktop/Window.hpp | 6 +- src/helpers/BezierCurve.cpp | 16 +++--- src/helpers/BezierCurve.hpp | 4 +- src/helpers/Monitor.cpp | 4 +- src/helpers/Monitor.hpp | 2 +- src/layout/DwindleLayout.cpp | 24 ++++---- src/layout/DwindleLayout.hpp | 4 +- src/layout/MasterLayout.hpp | 2 +- src/managers/AnimationManager.cpp | 2 +- src/managers/EventManager.cpp | 2 +- src/managers/EventManager.hpp | 8 +-- src/managers/KeybindManager.cpp | 2 +- src/managers/KeybindManager.hpp | 56 +++++++++--------- src/managers/input/InputManager.hpp | 2 +- src/pch/pch.hpp | 1 - src/render/decorations/CHyprGroupBarDecoration.hpp | 30 +++++----- 25 files changed, 181 insertions(+), 157 deletions(-) diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 4092bca0..55c3cc7e 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -322,11 +321,11 @@ void instancesRequest(bool json) { log(result + "\n"); } -std::deque splitArgs(int argc, char** argv) { - std::deque result; +std::vector splitArgs(int argc, char** argv) { + std::vector result; for (auto i = 1 /* skip the executable */; i < argc; ++i) - result.push_back(std::string(argv[i])); + result.emplace_back(argv[i]); return result; } diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 3047f2ea..4276a74e 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1349,13 +1349,13 @@ void CCompositor::changeWindowZOrder(PHLWINDOW pWindow, bool top) { else { // move X11 window stack - std::deque toMove; + std::vector toMove; - auto x11Stack = [&](PHLWINDOW pw, bool top, auto&& x11Stack) -> void { + auto x11Stack = [&](PHLWINDOW pw, bool top, auto&& x11Stack) -> void { if (top) toMove.emplace_back(pw); else - toMove.emplace_front(pw); + toMove.insert(toMove.begin(), pw); for (auto const& w : m_vWindows) { if (w->m_bIsMapped && !w->isHidden() && w->m_bIsX11 && w->x11TransientFor() == pw && w != pw && std::find(toMove.begin(), toMove.end(), w) == toMove.end()) { diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 90ac393c..96c2c5fe 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 36e73422..d81e3947 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -838,16 +838,16 @@ void CConfigManager::setDefaultAnimationVars() { } std::optional CConfigManager::resetHLConfig() { - m_dMonitorRules.clear(); - m_dWindowRules.clear(); + m_vMonitorRules.clear(); + m_vWindowRules.clear(); g_pKeybindManager->clearKeybinds(); g_pAnimationManager->removeAllBeziers(); m_mAdditionalReservedAreas.clear(); m_dBlurLSNamespaces.clear(); - m_dWorkspaceRules.clear(); + m_vWorkspaceRules.clear(); setDefaultAnimationVars(); // reset anims m_vDeclaredPlugins.clear(); - m_dLayerRules.clear(); + m_vLayerRules.clear(); m_vFailedPluginConfigValues.clear(); finalExecRequests.clear(); @@ -1154,7 +1154,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const PHLMONITOR PMONITOR) { return rule; }; - for (auto const& r : m_dMonitorRules | std::views::reverse) { + for (auto const& r : m_vMonitorRules | std::views::reverse) { if (PMONITOR->matchesStaticSelector(r.name)) { return applyWlrOutputConfig(r); } @@ -1162,7 +1162,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const PHLMONITOR PMONITOR) { Debug::log(WARN, "No rule found for {}, trying to use the first.", PMONITOR->szName); - for (auto const& r : m_dMonitorRules) { + for (auto const& r : m_vMonitorRules) { if (r.name.empty()) { return applyWlrOutputConfig(r); } @@ -1179,7 +1179,7 @@ SMonitorRule CConfigManager::getMonitorRuleFor(const PHLMONITOR PMONITOR) { SWorkspaceRule CConfigManager::getWorkspaceRuleFor(PHLWORKSPACE pWorkspace) { SWorkspaceRule mergedRule{}; - for (auto const& rule : m_dWorkspaceRules) { + for (auto const& rule : m_vWorkspaceRules) { if (!pWorkspace->matchesStaticSelector(rule.workspaceString)) continue; @@ -1252,7 +1252,7 @@ std::vector CConfigManager::getMatchingRules(PHLWINDOW pWindow, boo // local tags for dynamic tag rule match auto tags = pWindow->m_tags; - for (auto const& rule : m_dWindowRules) { + for (auto const& rule : m_vWindowRules) { // check if we have a matching rule if (!rule.v2) { try { @@ -1437,7 +1437,7 @@ std::vector CConfigManager::getMatchingRules(PHLLS pLS) { if (!pLS->layerSurface || pLS->fadingOut) return returns; - for (auto const& lr : m_dLayerRules) { + for (auto const& lr : m_vLayerRules) { if (lr.targetNamespace.starts_with("address:0x")) { if (std::format("address:0x{:x}", (uintptr_t)pLS.get()) != lr.targetNamespace) continue; @@ -1510,13 +1510,13 @@ void CConfigManager::dispatchExecShutdown() { } void CConfigManager::appendMonitorRule(const SMonitorRule& r) { - m_dMonitorRules.emplace_back(r); + m_vMonitorRules.emplace_back(r); } bool CConfigManager::replaceMonitorRule(const SMonitorRule& newrule) { // Looks for an existing monitor rule (compared by name). // If the rule exists, it is replaced with the input rule. - for (auto& r : m_dMonitorRules) { + for (auto& r : m_vMonitorRules) { if (r.name == newrule.name) { r = newrule; return true; @@ -1693,7 +1693,7 @@ PHLMONITOR CConfigManager::getBoundMonitorForWS(const std::string& wsname) { } std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname) { - for (auto const& wr : m_dWorkspaceRules) { + for (auto const& wr : m_vWorkspaceRules) { const auto WSNAME = wr.workspaceName.starts_with("name:") ? wr.workspaceName.substr(5) : wr.workspaceName; if (WSNAME == wsname) @@ -1703,8 +1703,8 @@ std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname return ""; } -const std::deque& CConfigManager::getAllWorkspaceRules() { - return m_dWorkspaceRules; +const std::vector& CConfigManager::getAllWorkspaceRules() { + return m_vWorkspaceRules; } void CConfigManager::addExecRule(const SExecRequestedRule& rule) { @@ -1782,7 +1782,7 @@ void CConfigManager::removePluginConfig(HANDLE handle) { } std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) { - for (auto other = m_dWorkspaceRules.begin(); other != m_dWorkspaceRules.end(); ++other) { + for (auto other = m_vWorkspaceRules.begin(); other != m_vWorkspaceRules.end(); ++other) { if (other->isDefault) { if (other->monitor == name) return other->workspaceString; @@ -1900,7 +1900,7 @@ std::optional CConfigManager::handleMonitor(const std::string& comm const auto TRANSFORM = (wl_output_transform)TSF; // overwrite if exists - for (auto& r : m_dMonitorRules) { + for (auto& r : m_vMonitorRules) { if (r.name == newrule.name) { r.transform = TRANSFORM; return {}; @@ -1925,9 +1925,9 @@ std::optional CConfigManager::handleMonitor(const std::string& comm return "parse error: curitem bogus"; } - std::erase_if(m_dMonitorRules, [&](const auto& other) { return other.name == newrule.name; }); + std::erase_if(m_vMonitorRules, [&](const auto& other) { return other.name == newrule.name; }); - m_dMonitorRules.push_back(newrule); + m_vMonitorRules.push_back(newrule); return {}; } @@ -1960,7 +1960,7 @@ std::optional CConfigManager::handleMonitor(const std::string& comm if (ARGS[2].starts_with("auto")) { newrule.offset = Vector2D(-INT32_MAX, -INT32_MAX); // If this is the first monitor rule needs to be on the right. - if (ARGS[2] == "auto-right" || ARGS[2] == "auto" || m_dMonitorRules.empty()) + if (ARGS[2] == "auto-right" || ARGS[2] == "auto" || m_vMonitorRules.empty()) newrule.autoDir = eAutoDirs::DIR_AUTO_RIGHT; else if (ARGS[2] == "auto-left") newrule.autoDir = eAutoDirs::DIR_AUTO_LEFT; @@ -2043,7 +2043,7 @@ std::optional CConfigManager::handleMonitor(const std::string& comm wsRule.workspaceId = id; wsRule.workspaceName = name; - m_dWorkspaceRules.emplace_back(wsRule); + m_vWorkspaceRules.emplace_back(wsRule); argno++; } else { Debug::log(ERR, "Config error: invalid monitor syntax at \"{}\"", ARGS[argno]); @@ -2053,9 +2053,9 @@ std::optional CConfigManager::handleMonitor(const std::string& comm argno++; } - std::erase_if(m_dMonitorRules, [&](const auto& other) { return other.name == newrule.name; }); + std::erase_if(m_vMonitorRules, [&](const auto& other) { return other.name == newrule.name; }); - m_dMonitorRules.push_back(newrule); + m_vMonitorRules.push_back(newrule); if (error.empty()) return {}; @@ -2338,7 +2338,7 @@ std::optional CConfigManager::handleWindowRule(const std::string& c return "empty rule?"; if (RULE == "unset") { - std::erase_if(m_dWindowRules, [&](const SWindowRule& other) { return other.szValue == VALUE; }); + std::erase_if(m_vWindowRules, [&](const SWindowRule& other) { return other.szValue == VALUE; }); return {}; } @@ -2349,9 +2349,9 @@ std::optional CConfigManager::handleWindowRule(const std::string& c } if (RULE.starts_with("size") || RULE.starts_with("maxsize") || RULE.starts_with("minsize")) - m_dWindowRules.push_front({RULE, VALUE}); + m_vWindowRules.insert(m_vWindowRules.begin(), {RULE, VALUE}); else - m_dWindowRules.push_back({RULE, VALUE}); + m_vWindowRules.push_back({RULE, VALUE}); return {}; } @@ -2365,7 +2365,7 @@ std::optional CConfigManager::handleLayerRule(const std::string& co return "empty rule?"; if (RULE == "unset") { - std::erase_if(m_dLayerRules, [&](const SLayerRule& other) { return other.targetNamespace == VALUE; }); + std::erase_if(m_vLayerRules, [&](const SLayerRule& other) { return other.targetNamespace == VALUE; }); return {}; } @@ -2374,7 +2374,7 @@ std::optional CConfigManager::handleLayerRule(const std::string& co return "Invalid rule found: " + RULE; } - m_dLayerRules.push_back({VALUE, RULE}); + m_vLayerRules.push_back({VALUE, RULE}); for (auto const& m : g_pCompositor->m_vMonitors) for (auto const& lsl : m->m_aLayerSurfaceLayers) @@ -2512,7 +2512,7 @@ std::optional CConfigManager::handleWindowRuleV2(const std::string& rule.szOnWorkspace = extract(ONWORKSPACEPOS + 12); if (RULE == "unset") { - std::erase_if(m_dWindowRules, [&](const SWindowRule& other) { + std::erase_if(m_vWindowRules, [&](const SWindowRule& other) { if (!other.v2) { return other.szClass == rule.szClass && !rule.szClass.empty(); } else { @@ -2562,9 +2562,9 @@ std::optional CConfigManager::handleWindowRuleV2(const std::string& } if (RULE.starts_with("size") || RULE.starts_with("maxsize") || RULE.starts_with("minsize")) - m_dWindowRules.push_front(rule); + m_vWindowRules.insert(m_vWindowRules.begin(), rule); else - m_dWindowRules.push_back(rule); + m_vWindowRules.push_back(rule); return {}; } @@ -2713,10 +2713,10 @@ std::optional CConfigManager::handleWorkspaceRules(const std::strin wsRule.workspaceId = id; wsRule.workspaceName = name; - const auto IT = std::find_if(m_dWorkspaceRules.begin(), m_dWorkspaceRules.end(), [&](const auto& other) { return other.workspaceString == wsRule.workspaceString; }); + const auto IT = std::find_if(m_vWorkspaceRules.begin(), m_vWorkspaceRules.end(), [&](const auto& other) { return other.workspaceString == wsRule.workspaceString; }); - if (IT == m_dWorkspaceRules.end()) - m_dWorkspaceRules.emplace_back(wsRule); + if (IT == m_vWorkspaceRules.end()) + m_vWorkspaceRules.emplace_back(wsRule); else *IT = mergeWorkspaceRules(*IT, wsRule); diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 2de217cb..7802d1e4 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -8,7 +8,6 @@ #include "../defines.hpp" #include #include -#include #include #include #include @@ -175,7 +174,7 @@ class CConfigManager { PHLMONITOR getBoundMonitorForWS(const std::string&); std::string getBoundMonitorStringForWS(const std::string&); - const std::deque& getAllWorkspaceRules(); + const std::vector& getAllWorkspaceRules(); std::vector getMatchingRules(PHLWINDOW, bool dynamic = true, bool shadowExec = false); std::vector getMatchingRules(PHLLS); @@ -275,7 +274,7 @@ class CConfigManager { private: std::unique_ptr m_pConfig; - std::deque configPaths; // stores all the config paths + std::vector configPaths; // stores all the config paths std::unordered_map configModifyTimes; // stores modify times std::unordered_map animationConfig; // stores all the animations with their set values @@ -290,16 +289,16 @@ class CConfigManager { bool isFirstLaunch = true; // For exec-once - std::deque m_dMonitorRules; - std::deque m_dWorkspaceRules; - std::deque m_dWindowRules; - std::deque m_dLayerRules; - std::deque m_dBlurLSNamespaces; + std::vector m_vMonitorRules; + std::vector m_vWorkspaceRules; + std::vector m_vWindowRules; + std::vector m_vLayerRules; + std::vector m_dBlurLSNamespaces; bool firstExecDispatched = false; bool m_bManualCrashInitiated = false; - std::deque firstExecRequests; - std::deque finalExecRequests; + std::vector firstExecRequests; + std::vector finalExecRequests; std::vector> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins std::string m_szConfigErrors = ""; diff --git a/src/debug/HyprDebugOverlay.cpp b/src/debug/HyprDebugOverlay.cpp index 9326cfe0..0df46086 100644 --- a/src/debug/HyprDebugOverlay.cpp +++ b/src/debug/HyprDebugOverlay.cpp @@ -8,7 +8,12 @@ CHyprDebugOverlay::CHyprDebugOverlay() { } void CHyprMonitorDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) { - m_dLastRenderTimes.push_back(durationUs / 1000.f); + static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); + + if (!*PDEBUGOVERLAY) + return; + + m_dLastRenderTimes.emplace_back(durationUs / 1000.f); if (m_dLastRenderTimes.size() > (long unsigned int)pMonitor->refreshRate) m_dLastRenderTimes.pop_front(); @@ -18,7 +23,12 @@ void CHyprMonitorDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) } void CHyprMonitorDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) { - m_dLastRenderTimesNoOverlay.push_back(durationUs / 1000.f); + static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); + + if (!*PDEBUGOVERLAY) + return; + + m_dLastRenderTimesNoOverlay.emplace_back(durationUs / 1000.f); if (m_dLastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->refreshRate) m_dLastRenderTimesNoOverlay.pop_front(); @@ -28,7 +38,12 @@ void CHyprMonitorDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float du } void CHyprMonitorDebugOverlay::frameData(PHLMONITOR pMonitor) { - m_dLastFrametimes.push_back(std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f); + static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); + + if (!*PDEBUGOVERLAY) + return; + + m_dLastFrametimes.emplace_back(std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f); if (m_dLastFrametimes.size() > (long unsigned int)pMonitor->refreshRate) m_dLastFrametimes.pop_front(); @@ -189,14 +204,29 @@ int CHyprMonitorDebugOverlay::draw(int offset) { } void CHyprDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) { + static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); + + if (!*PDEBUGOVERLAY) + return; + m_mMonitorOverlays[pMonitor].renderData(pMonitor, durationUs); } void CHyprDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) { + static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); + + if (!*PDEBUGOVERLAY) + return; + m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, durationUs); } void CHyprDebugOverlay::frameData(PHLMONITOR pMonitor) { + static auto PDEBUGOVERLAY = CConfigValue("debug:overlay"); + + if (!*PDEBUGOVERLAY) + return; + m_mMonitorOverlays[pMonitor].frameData(pMonitor); } diff --git a/src/debug/HyprDebugOverlay.hpp b/src/debug/HyprDebugOverlay.hpp index 89d1d606..42cdac55 100644 --- a/src/debug/HyprDebugOverlay.hpp +++ b/src/debug/HyprDebugOverlay.hpp @@ -3,9 +3,9 @@ #include "../defines.hpp" #include "../helpers/Monitor.hpp" #include "../render/Texture.hpp" -#include #include #include +#include class CHyprRenderer; diff --git a/src/debug/HyprNotificationOverlay.cpp b/src/debug/HyprNotificationOverlay.cpp index 482db541..153d2395 100644 --- a/src/debug/HyprNotificationOverlay.cpp +++ b/src/debug/HyprNotificationOverlay.cpp @@ -18,7 +18,7 @@ inline auto iconBackendFromLayout(PangoLayout* layout) { CHyprNotificationOverlay::CHyprNotificationOverlay() { static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) { - if (m_dNotifications.size() == 0) + if (m_vNotifications.size() == 0) return; g_pHyprRenderer->damageBox(&m_bLastDamage); @@ -35,7 +35,7 @@ CHyprNotificationOverlay::~CHyprNotificationOverlay() { } void CHyprNotificationOverlay::addNotification(const std::string& text, const CHyprColor& color, const float timeMs, const eIcons icon, const float fontSize) { - const auto PNOTIF = m_dNotifications.emplace_back(std::make_unique()).get(); + const auto PNOTIF = m_vNotifications.emplace_back(std::make_unique()).get(); PNOTIF->text = icon != eIcons::ICON_NONE ? " " + text /* tiny bit of padding otherwise icon touches text */ : text; PNOTIF->color = color == CHyprColor(0) ? ICONS_COLORS[icon] : color; @@ -51,12 +51,12 @@ void CHyprNotificationOverlay::addNotification(const std::string& text, const CH void CHyprNotificationOverlay::dismissNotifications(const int amount) { if (amount == -1) - m_dNotifications.clear(); + m_vNotifications.clear(); else { - const int AMT = std::min(amount, static_cast(m_dNotifications.size())); + const int AMT = std::min(amount, static_cast(m_vNotifications.size())); for (int i = 0; i < AMT; ++i) { - m_dNotifications.pop_front(); + m_vNotifications.erase(m_vNotifications.begin()); } } } @@ -87,7 +87,7 @@ CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) { const auto iconBackendID = iconBackendFromLayout(layout); const auto PBEZIER = g_pAnimationManager->getBezier("default"); - for (auto const& notif : m_dNotifications) { + for (auto const& notif : m_vNotifications) { const auto ICONPADFORNOTIF = notif->icon == ICON_NONE ? 0 : ICON_PAD; const auto FONTSIZE = std::clamp((int)(notif->fontSize * ((pMonitor->vecPixelSize.x * SCALE) / 1920.f)), 8, 40); @@ -182,7 +182,7 @@ CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) { g_object_unref(layout); // cleanup notifs - std::erase_if(m_dNotifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; }); + std::erase_if(m_vNotifications, [](const auto& notif) { return notif->started.getMillis() > notif->timeMs; }); return CBox{(int)(pMonitor->vecPosition.x + pMonitor->vecSize.x - maxWidth - 20), (int)pMonitor->vecPosition.y, (int)maxWidth + 20, (int)offsetY + 10}; } @@ -205,7 +205,7 @@ void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) { } // Draw the notifications - if (m_dNotifications.size() == 0) + if (m_vNotifications.size() == 0) return; // Render to the monitor @@ -246,5 +246,5 @@ void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) { } bool CHyprNotificationOverlay::hasAny() { - return !m_dNotifications.empty(); + return !m_vNotifications.empty(); } diff --git a/src/debug/HyprNotificationOverlay.hpp b/src/debug/HyprNotificationOverlay.hpp index 5e88ebc0..3ff0b35c 100644 --- a/src/debug/HyprNotificationOverlay.hpp +++ b/src/debug/HyprNotificationOverlay.hpp @@ -6,7 +6,7 @@ #include "../render/Texture.hpp" #include "../SharedDefs.hpp" -#include +#include #include @@ -47,18 +47,18 @@ class CHyprNotificationOverlay { bool hasAny(); private: - CBox drawNotifications(PHLMONITOR pMonitor); - CBox m_bLastDamage; + CBox drawNotifications(PHLMONITOR pMonitor); + CBox m_bLastDamage; - std::deque> m_dNotifications; + std::vector> m_vNotifications; - cairo_surface_t* m_pCairoSurface = nullptr; - cairo_t* m_pCairo = nullptr; + cairo_surface_t* m_pCairoSurface = nullptr; + cairo_t* m_pCairo = nullptr; - PHLMONITORREF m_pLastMonitor; - Vector2D m_vecLastSize = Vector2D(-1, -1); + PHLMONITORREF m_pLastMonitor; + Vector2D m_vecLastSize = Vector2D(-1, -1); - SP m_pTexture; + SP m_pTexture; }; inline std::unique_ptr g_pHyprNotificationOverlay; diff --git a/src/desktop/Window.hpp b/src/desktop/Window.hpp index 590194e1..f57d6e60 100644 --- a/src/desktop/Window.hpp +++ b/src/desktop/Window.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "../config/ConfigDataValues.hpp" @@ -344,8 +344,8 @@ class CWindow { // Window decorations // TODO: make this a SP. - std::deque> m_dWindowDecorations; - std::vector m_vDecosToRemove; + std::vector> m_dWindowDecorations; + std::vector m_vDecosToRemove; // Special render data, rules, etc SWindowData m_sWindowData; diff --git a/src/helpers/BezierCurve.cpp b/src/helpers/BezierCurve.cpp index 23fcd691..ec093888 100644 --- a/src/helpers/BezierCurve.cpp +++ b/src/helpers/BezierCurve.cpp @@ -9,18 +9,18 @@ void CBezierCurve::setup(std::vector* pVec) { const auto BEGIN = std::chrono::high_resolution_clock::now(); // Avoid reallocations by reserving enough memory upfront - m_dPoints.resize(pVec->size() + 2); - m_dPoints[0] = Vector2D(0, 0); // Start point + m_vPoints.resize(pVec->size() + 2); + m_vPoints[0] = Vector2D(0, 0); // Start point size_t index = 1; // Start after the first element for (const auto& vec : *pVec) { - if (index < m_dPoints.size() - 1) { // Bounds check to ensure safety - m_dPoints[index] = vec; + if (index < m_vPoints.size() - 1) { // Bounds check to ensure safety + m_vPoints[index] = vec; ++index; } } - m_dPoints.back() = Vector2D(1, 1); // End point + m_vPoints.back() = Vector2D(1, 1); // End point - RASSERT(m_dPoints.size() == 4, "CBezierCurve only supports cubic beziers! (points num: {})", m_dPoints.size()); + RASSERT(m_vPoints.size() == 4, "CBezierCurve only supports cubic beziers! (points num: {})", m_vPoints.size()); // bake BAKEDPOINTS points for faster lookups // T -> X ( / BAKEDPOINTS ) @@ -47,14 +47,14 @@ float CBezierCurve::getXForT(float const& t) { float t2 = t * t; float t3 = t2 * t; - return 3 * t * (1 - t) * (1 - t) * m_dPoints[1].x + 3 * t2 * (1 - t) * m_dPoints[2].x + t3 * m_dPoints[3].x; + return 3 * t * (1 - t) * (1 - t) * m_vPoints[1].x + 3 * t2 * (1 - t) * m_vPoints[2].x + t3 * m_vPoints[3].x; } float CBezierCurve::getYForT(float const& t) { float t2 = t * t; float t3 = t2 * t; - return 3 * t * (1 - t) * (1 - t) * m_dPoints[1].y + 3 * t2 * (1 - t) * m_dPoints[2].y + t3 * m_dPoints[3].y; + return 3 * t * (1 - t) * (1 - t) * m_vPoints[1].y + 3 * t2 * (1 - t) * m_vPoints[2].y + t3 * m_vPoints[3].y; } // Todo: this probably can be done better and faster diff --git a/src/helpers/BezierCurve.hpp b/src/helpers/BezierCurve.hpp index 1a842f5a..1b9144a8 100644 --- a/src/helpers/BezierCurve.hpp +++ b/src/helpers/BezierCurve.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include "math/Math.hpp" @@ -22,7 +22,7 @@ class CBezierCurve { private: // this INCLUDES the 0,0 and 1,1 points. - std::vector m_dPoints; + std::vector m_vPoints; std::array m_aPointsBaked; }; diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 4d503fe9..8d1597be 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -314,7 +314,7 @@ void CMonitor::onDisconnect(bool destroy) { g_pCompositor->warpCursorTo(BACKUPMON->vecPosition + BACKUPMON->vecTransformedSize / 2.F, true); // move workspaces - std::deque wspToMove; + std::vector wspToMove; for (auto const& w : g_pCompositor->m_vWorkspaces) { if (w->m_pMonitor == self || !w->m_pMonitor) wspToMove.push_back(w); @@ -541,7 +541,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) { } // move all the WS - std::deque wspToMove; + std::vector wspToMove; for (auto const& w : g_pCompositor->m_vWorkspaces) { if (w->m_pMonitor == self || !w->m_pMonitor) wspToMove.push_back(w); diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index c8ef3c7b..38c55572 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -1,7 +1,7 @@ #pragma once #include "../defines.hpp" -#include +#include #include "WLClasses.hpp" #include #include diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 32df7676..ec874223 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -38,13 +38,12 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force, bool horizontalOverrid } } -void SDwindleNodeData::getAllChildrenRecursive(std::deque* pDeque) { +void SDwindleNodeData::getAllChildrenRecursive(std::vector* pVec) { if (children[0]) { - children[0]->getAllChildrenRecursive(pDeque); - children[1]->getAllChildrenRecursive(pDeque); - } else { - pDeque->push_back(this); - } + children[0]->getAllChildrenRecursive(pVec); + children[1]->getAllChildrenRecursive(pVec); + } else + pVec->push_back(this); } int CHyprDwindleLayout::getNodesOnWorkspace(const WORKSPACEID& id) { @@ -805,14 +804,13 @@ void CHyprDwindleLayout::recalculateWindow(PHLWINDOW pWindow) { PNODE->recalcSizePosRecursive(); } -void addToDequeRecursive(std::deque* pDeque, std::deque* pParents, SDwindleNodeData* node) { +static void addToVectorRecursive(std::vector* pVec, std::vector* pParents, SDwindleNodeData* node) { if (node->isNode) { - pParents->push_back(node); - addToDequeRecursive(pDeque, pParents, node->children[0]); - addToDequeRecursive(pDeque, pParents, node->children[1]); - } else { - pDeque->emplace_back(node); - } + pParents->emplace_back(node); + addToVectorRecursive(pVec, pParents, node->children[0]); + addToVectorRecursive(pVec, pParents, node->children[1]); + } else + pVec->emplace_back(node); } SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(PHLWINDOW pWindow) { diff --git a/src/layout/DwindleLayout.hpp b/src/layout/DwindleLayout.hpp index 953ba3a2..dffc34f7 100644 --- a/src/layout/DwindleLayout.hpp +++ b/src/layout/DwindleLayout.hpp @@ -4,7 +4,7 @@ #include "../desktop/DesktopTypes.hpp" #include -#include +#include #include #include #include @@ -39,7 +39,7 @@ struct SDwindleNodeData { } void recalcSizePosRecursive(bool force = false, bool horizontalOverride = false, bool verticalOverride = false); - void getAllChildrenRecursive(std::deque*); + void getAllChildrenRecursive(std::vector*); CHyprDwindleLayout* layout = nullptr; }; diff --git a/src/layout/MasterLayout.hpp b/src/layout/MasterLayout.hpp index b72be74f..4841ef08 100644 --- a/src/layout/MasterLayout.hpp +++ b/src/layout/MasterLayout.hpp @@ -5,7 +5,7 @@ #include "../config/ConfigManager.hpp" #include #include -#include +#include #include enum eFullscreenMode : int8_t; diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 5ebbea8a..a61c20a1 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -301,7 +301,7 @@ void CAnimationManager::tick() { g_pCompositor->scheduleFrameForMonitor(PMONITOR, Aquamarine::IOutput::AQ_SCHEDULE_ANIMATION); } - // do it here, because if this alters the animation vars deque we would be in trouble above. + // do it here, because if this alters the animation vars vec we would be in trouble above. for (auto const& ave : animationEndedVars) { ave->onAnimationEnd(); } diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp index 786468f2..fc55b472 100644 --- a/src/managers/EventManager.cpp +++ b/src/managers/EventManager.cpp @@ -116,7 +116,7 @@ int CEventManager::onClientEvent(int fd, uint32_t mask) { if (write(CLIENTIT->fd, event->c_str(), event->length()) < 0) break; - CLIENTIT->events.pop_front(); + CLIENTIT->events.erase(CLIENTIT->events.begin()); } // stop polling when we sent all events diff --git a/src/managers/EventManager.hpp b/src/managers/EventManager.hpp index 383d3246..37716e63 100644 --- a/src/managers/EventManager.hpp +++ b/src/managers/EventManager.hpp @@ -1,5 +1,5 @@ #pragma once -#include +#include #include #include "../defines.hpp" @@ -27,9 +27,9 @@ class CEventManager { int onClientEvent(int fd, uint32_t mask); struct SClient { - int fd = -1; - std::deque> events; - wl_event_source* eventSource = nullptr; + int fd = -1; + std::vector> events; + wl_event_source* eventSource = nullptr; }; std::vector::iterator findClientByFD(int fd); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 8afa330b..f23f5dc7 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1776,7 +1776,7 @@ SDispatchResult CKeybindManager::workspaceOpt(std::string args) { // apply // we make a copy because changeWindowFloatingMode might invalidate the iterator - std::deque ptrs; + std::vector ptrs; for (auto const& w : g_pCompositor->m_vWindows) ptrs.push_back(w); diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index f524f86f..6486ac3b 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -1,7 +1,7 @@ #pragma once #include "../defines.hpp" -#include +#include #include #include #include @@ -116,45 +116,45 @@ class CKeybindManager { static SDispatchResult changeMouseBindMode(const eMouseBindMode mode); private: - std::deque m_dPressedKeys; + std::vector m_dPressedKeys; - inline static std::string m_szCurrentSelectedSubmap = ""; + inline static std::string m_szCurrentSelectedSubmap = ""; - std::vector> m_vActiveKeybinds; - WP m_pLastLongPressKeybind; - SP m_pLongPressTimer, m_pRepeatKeyTimer; + std::vector> m_vActiveKeybinds; + WP m_pLastLongPressKeybind; + SP m_pLongPressTimer, m_pRepeatKeyTimer; - uint32_t m_uTimeLastMs = 0; - uint32_t m_uLastCode = 0; - uint32_t m_uLastMouseCode = 0; + uint32_t m_uTimeLastMs = 0; + uint32_t m_uLastCode = 0; + uint32_t m_uLastMouseCode = 0; - std::vector> m_vPressedSpecialBinds; + std::vector> m_vPressedSpecialBinds; - int m_iPassPressed = -1; // used for pass + int m_iPassPressed = -1; // used for pass - CTimer m_tScrollTimer; + CTimer m_tScrollTimer; - SDispatchResult handleKeybinds(const uint32_t, const SPressedKeyWithMods&, bool); + SDispatchResult handleKeybinds(const uint32_t, const SPressedKeyWithMods&, bool); - std::set m_sMkKeys = {}; - std::set m_sMkMods = {}; - eMultiKeyCase mkBindMatches(const SP); - eMultiKeyCase mkKeysymSetMatches(const std::set, const std::set); + std::set m_sMkKeys = {}; + std::set m_sMkMods = {}; + eMultiKeyCase mkBindMatches(const SP); + eMultiKeyCase mkKeysymSetMatches(const std::set, const std::set); - bool handleInternalKeybinds(xkb_keysym_t); - bool handleVT(xkb_keysym_t); + bool handleInternalKeybinds(xkb_keysym_t); + bool handleVT(xkb_keysym_t); - xkb_state* m_pXKBTranslationState = nullptr; + xkb_state* m_pXKBTranslationState = nullptr; - void updateXKBTranslationState(); - bool ensureMouseBindState(); + void updateXKBTranslationState(); + bool ensureMouseBindState(); - static bool tryMoveFocusToMonitor(PHLMONITOR monitor); - static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = ""); - static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection); - static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO); - static uint64_t spawnRawProc(std::string, PHLWORKSPACE pInitialWorkspace); - static uint64_t spawnWithRules(std::string, PHLWORKSPACE pInitialWorkspace); + static bool tryMoveFocusToMonitor(PHLMONITOR monitor); + static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = ""); + static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection); + static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO); + static uint64_t spawnRawProc(std::string, PHLWORKSPACE pInitialWorkspace); + static uint64_t spawnWithRules(std::string, PHLWORKSPACE pInitialWorkspace); // -------------- Dispatchers -------------- // static SDispatchResult killActive(std::string); diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index bc73d2cc..36c8144d 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -163,7 +163,7 @@ class CInputManager { std::list m_lSwitches; // Exclusive layer surfaces - std::deque m_dExclusiveLSes; + std::vector m_dExclusiveLSes; // constraints std::vector> m_vConstraints; diff --git a/src/pch/pch.hpp b/src/pch/pch.hpp index bfafee9e..eaec129b 100644 --- a/src/pch/pch.hpp +++ b/src/pch/pch.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp index 338a8449..e813d140 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.hpp +++ b/src/render/decorations/CHyprGroupBarDecoration.hpp @@ -2,7 +2,7 @@ #include "IHyprWindowDecoration.hpp" #include "../../devices/IPointer.hpp" -#include +#include #include "../Texture.hpp" #include #include @@ -48,29 +48,29 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration { virtual std::string getDisplayName(); private: - SBoxExtents m_seExtents; + SBoxExtents m_seExtents; - CBox m_bAssignedBox = {0}; + CBox m_bAssignedBox = {0}; - PHLWINDOWREF m_pWindow; + PHLWINDOWREF m_pWindow; - std::deque m_dwGroupMembers; + std::vector m_dwGroupMembers; - float m_fBarWidth; - float m_fBarHeight; + float m_fBarWidth; + float m_fBarHeight; - CTitleTex* textureFromTitle(const std::string&); - void invalidateTextures(); + CTitleTex* textureFromTitle(const std::string&); + void invalidateTextures(); - CBox assignedBoxGlobal(); + CBox assignedBoxGlobal(); - bool onBeginWindowDragOnDeco(const Vector2D&); - bool onEndWindowDragOnDeco(const Vector2D&, PHLWINDOW); - bool onMouseButtonOnDeco(const Vector2D&, const IPointer::SButtonEvent&); - bool onScrollOnDeco(const Vector2D&, const IPointer::SAxisEvent); + bool onBeginWindowDragOnDeco(const Vector2D&); + bool onEndWindowDragOnDeco(const Vector2D&, PHLWINDOW); + bool onMouseButtonOnDeco(const Vector2D&, const IPointer::SButtonEvent&); + bool onScrollOnDeco(const Vector2D&, const IPointer::SAxisEvent); struct STitleTexs { // STitleTexs* overriden = nullptr; // TODO: make shit shared in-group to decrease VRAM usage. - std::deque> titleTexs; + std::vector> titleTexs; } m_sTitleTexs; }; -- cgit v1.2.3