diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-12-07 18:51:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-07 18:51:18 +0100 |
| commit | 8bbeee11734d3ba8e2cf15d19cb3c302f8bfdbf2 (patch) | |
| tree | 5b6654818049a0743f62defc090e86d4327cccbb /src/config | |
| parent | b1e5cc66bdb20b002c93479490c3a317552210b3 (diff) | |
core: Add clang-tidy (#8664)
This adds a .clang-tidy file for us.
It's not a strict requirement to be compliant, but I tuned it to be alright.
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/ConfigDataValues.hpp | 6 | ||||
| -rw-r--r-- | src/config/ConfigManager.cpp | 24 | ||||
| -rw-r--r-- | src/config/ConfigManager.hpp | 98 | ||||
| -rw-r--r-- | src/config/ConfigValue.hpp | 1 |
4 files changed, 67 insertions, 62 deletions
diff --git a/src/config/ConfigDataValues.hpp b/src/config/ConfigDataValues.hpp index 212f26fa..80e45a05 100644 --- a/src/config/ConfigDataValues.hpp +++ b/src/config/ConfigDataValues.hpp @@ -3,7 +3,7 @@ #include "../helpers/varlist/VarList.hpp" #include <vector> -enum eConfigValueDataTypes { +enum eConfigValueDataTypes : int8_t { CVD_TYPE_INVALID = -1, CVD_TYPE_GRADIENT = 0, CVD_TYPE_CSS_VALUE = 1 @@ -20,12 +20,12 @@ class ICustomConfigValueData { class CGradientValueData : public ICustomConfigValueData { public: - CGradientValueData() {}; + CGradientValueData() = default; CGradientValueData(CHyprColor col) { m_vColors.push_back(col); updateColorsOk(); }; - virtual ~CGradientValueData() {}; + virtual ~CGradientValueData() = default; virtual eConfigValueDataTypes getDataType() { return CVD_TYPE_GRADIENT; diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 50fbe403..ce474f94 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1,5 +1,6 @@ #include "ConfigManager.hpp" #include "../managers/KeybindManager.hpp" +#include "../Compositor.hpp" #include "../render/decorations/CHyprGroupBarDecoration.hpp" #include "config/ConfigDataValues.hpp" @@ -12,7 +13,7 @@ #include <cstddef> #include <cstdint> #include <hyprutils/path/Path.hpp> -#include <string.h> +#include <cstring> #include <string> #include <sys/stat.h> #include <sys/types.h> @@ -30,6 +31,7 @@ #include <filesystem> using namespace Hyprutils::String; +//NOLINTNEXTLINE extern "C" char** environ; #include "ConfigDescriptions.hpp" @@ -70,7 +72,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void** const auto COL = configStringToInt(var); if (!COL) throw std::runtime_error(std::format("failed to parse {} as a color", var)); - DATA->m_vColors.push_back(CHyprColor(COL.value())); + DATA->m_vColors.emplace_back(COL.value()); } catch (std::exception& e) { Debug::log(WARN, "Error parsing gradient {}", V); parseError = "Error parsing gradient " + V + ": " + e.what(); @@ -82,7 +84,7 @@ static Hyprlang::CParseResult configHandleGradientSet(const char* VALUE, void** if (parseError.empty()) parseError = "Error parsing gradient " + V + ": No colors?"; - DATA->m_vColors.push_back(0); // transparent + DATA->m_vColors.emplace_back(0); // transparent } DATA->updateColorsOk(); @@ -736,7 +738,7 @@ const std::string CConfigManager::getConfigString() { std::string configString; std::string currFileContent; - for (auto path : configPaths) { + for (const auto& path : configPaths) { std::ifstream configFile(path); configString += ("\n\nConfig File: " + path + ": "); if (!configFile.is_open()) { @@ -1100,7 +1102,7 @@ Vector2D CConfigManager::getDeviceVec(const std::string& dev, const std::string& } std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v, const std::string& fallback) { - const auto VAL = std::string{std::any_cast<Hyprlang::STRING>(getConfigValueSafeDevice(dev, v, fallback)->getValue())}; + auto VAL = std::string{std::any_cast<Hyprlang::STRING>(getConfigValueSafeDevice(dev, v, fallback)->getValue())}; if (VAL == STRVAL_EMPTY) return ""; @@ -1718,7 +1720,7 @@ void CConfigManager::handlePluginLoads() { std::stringstream error; error << "Failed to load the following plugins:"; - for (auto path : failedPlugins) { + for (const auto& path : failedPlugins) { error << "\n" << path; } @@ -2149,7 +2151,7 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co PANIM->second.internalStyle = ARGS[4]; if (ARGS[4] != "") { - const auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, ARGS[4]); + auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, ARGS[4]); if (ERR != "") return ERR; @@ -2238,10 +2240,10 @@ std::optional<std::string> CConfigManager::handleBind(const std::string& command std::set<xkb_keysym_t> MODS; if (multiKey) { - for (auto splitKey : CVarList(ARGS[1], 8, '&')) { + for (const auto& splitKey : CVarList(ARGS[1], 8, '&')) { KEYSYMS.insert(xkb_keysym_from_name(splitKey.c_str(), XKB_KEYSYM_CASE_INSENSITIVE)); } - for (auto splitMod : CVarList(ARGS[0], 8, '&')) { + for (const auto& splitMod : CVarList(ARGS[0], 8, '&')) { MODS.insert(xkb_keysym_from_name(splitMod.c_str(), XKB_KEYSYM_CASE_INSENSITIVE)); } } @@ -2687,8 +2689,8 @@ std::optional<std::string> CConfigManager::handleWorkspaceRules(const std::strin return "Invalid workspace rule found: " + rule; } - std::string val = opt.substr(opt.find(":") + 1); - opt = opt.substr(0, opt.find(":")); + std::string val = opt.substr(opt.find(':') + 1); + opt = opt.substr(0, opt.find(':')); wsRule.layoutopts[opt] = val; } diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index a3b86e69..987884b5 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -69,13 +69,13 @@ struct SAnimationPropertyConfig { }; struct SPluginKeyword { - HANDLE handle = 0; + HANDLE handle = nullptr; std::string name = ""; Hyprlang::PCONFIGHANDLERFUNC fn = nullptr; }; struct SPluginVariable { - HANDLE handle = 0; + HANDLE handle = nullptr; std::string name = ""; }; @@ -84,7 +84,7 @@ struct SExecRequestedRule { uint64_t iPid = 0; }; -enum eConfigOptionType : uint16_t { +enum eConfigOptionType : uint8_t { CONFIG_OPTION_BOOL = 0, CONFIG_OPTION_INT = 1, /* e.g. 0/1/2*/ CONFIG_OPTION_FLOAT = 2, @@ -96,7 +96,7 @@ enum eConfigOptionType : uint16_t { CONFIG_OPTION_VECTOR = 8, }; -enum eConfigOptionFlags : uint32_t { +enum eConfigOptionFlags : uint8_t { CONFIG_OPTION_FLAG_PERCENTAGE = (1 << 0), }; @@ -214,52 +214,54 @@ class CConfigManager { std::string getErrors(); // keywords - std::optional<std::string> handleRawExec(const std::string&, const std::string&); - std::optional<std::string> handleExecOnce(const std::string&, const std::string&); - std::optional<std::string> handleExecShutdown(const std::string&, const std::string&); - std::optional<std::string> handleMonitor(const std::string&, const std::string&); - std::optional<std::string> handleBind(const std::string&, const std::string&); - std::optional<std::string> handleUnbind(const std::string&, const std::string&); - std::optional<std::string> handleWindowRule(const std::string&, const std::string&); - std::optional<std::string> handleLayerRule(const std::string&, const std::string&); - std::optional<std::string> handleWindowRuleV2(const std::string&, const std::string&); - std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&); - std::optional<std::string> handleBezier(const std::string&, const std::string&); - std::optional<std::string> handleAnimation(const std::string&, const std::string&); - std::optional<std::string> handleSource(const std::string&, const std::string&); - std::optional<std::string> handleSubmap(const std::string&, const std::string&); - std::optional<std::string> handleBlurLS(const std::string&, const std::string&); - std::optional<std::string> handleBindWS(const std::string&, const std::string&); - std::optional<std::string> handleEnv(const std::string&, const std::string&); - std::optional<std::string> handlePlugin(const std::string&, const std::string&); - - std::string configCurrentPath; - - std::unordered_map<std::string, std::function<CWindowOverridableVar<bool>*(PHLWINDOW)>> mbWindowProperties = { - {"allowsinput", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.allowsInput; }}, - {"dimaround", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.dimAround; }}, - {"decorate", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.decorate; }}, - {"focusonactivate", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.focusOnActivate; }}, - {"keepaspectratio", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.keepAspectRatio; }}, - {"nearestneighbor", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.nearestNeighbor; }}, - {"noanim", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noAnim; }}, - {"noblur", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noBlur; }}, - {"noborder", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noBorder; }}, - {"nodim", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noDim; }}, - {"nofocus", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noFocus; }}, - {"nomaxsize", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noMaxSize; }}, - {"norounding", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noRounding; }}, - {"noshadow", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noShadow; }}, - {"noshortcutsinhibit", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.noShortcutsInhibit; }}, - {"opaque", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.opaque; }}, - {"forcergbx", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.RGBX; }}, - {"syncfullscreen", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.syncFullscreen; }}, - {"immediate", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.tearing; }}, - {"xray", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.xray; }}, + std::optional<std::string> handleRawExec(const std::string&, const std::string&); + std::optional<std::string> handleExecOnce(const std::string&, const std::string&); + std::optional<std::string> handleExecShutdown(const std::string&, const std::string&); + std::optional<std::string> handleMonitor(const std::string&, const std::string&); + std::optional<std::string> handleBind(const std::string&, const std::string&); + std::optional<std::string> handleUnbind(const std::string&, const std::string&); + std::optional<std::string> handleWindowRule(const std::string&, const std::string&); + std::optional<std::string> handleLayerRule(const std::string&, const std::string&); + std::optional<std::string> handleWindowRuleV2(const std::string&, const std::string&); + std::optional<std::string> handleWorkspaceRules(const std::string&, const std::string&); + std::optional<std::string> handleBezier(const std::string&, const std::string&); + std::optional<std::string> handleAnimation(const std::string&, const std::string&); + std::optional<std::string> handleSource(const std::string&, const std::string&); + std::optional<std::string> handleSubmap(const std::string&, const std::string&); + std::optional<std::string> handleBlurLS(const std::string&, const std::string&); + std::optional<std::string> handleBindWS(const std::string&, const std::string&); + std::optional<std::string> handleEnv(const std::string&, const std::string&); + std::optional<std::string> handlePlugin(const std::string&, const std::string&); + + std::string configCurrentPath; + + std::unordered_map<std::string, std::function<CWindowOverridableVar<bool>*(const PHLWINDOW&)>> mbWindowProperties = { + {"allowsinput", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.allowsInput; }}, + {"dimaround", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.dimAround; }}, + {"decorate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.decorate; }}, + {"focusonactivate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.focusOnActivate; }}, + {"keepaspectratio", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.keepAspectRatio; }}, + {"nearestneighbor", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.nearestNeighbor; }}, + {"noanim", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noAnim; }}, + {"noblur", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noBlur; }}, + {"noborder", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noBorder; }}, + {"nodim", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noDim; }}, + {"nofocus", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noFocus; }}, + {"nomaxsize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noMaxSize; }}, + {"norounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noRounding; }}, + {"noshadow", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noShadow; }}, + {"noshortcutsinhibit", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.noShortcutsInhibit; }}, + {"opaque", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.opaque; }}, + {"forcergbx", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.RGBX; }}, + {"syncfullscreen", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.syncFullscreen; }}, + {"immediate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.tearing; }}, + {"xray", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.xray; }}, }; - std::unordered_map<std::string, std::function<CWindowOverridableVar<int>*(PHLWINDOW)>> miWindowProperties = { - {"rounding", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.rounding; }}, {"bordersize", [](PHLWINDOW pWindow) { return &pWindow->m_sWindowData.borderSize; }}}; + std::unordered_map<std::string, std::function<CWindowOverridableVar<int>*(const PHLWINDOW&)>> miWindowProperties = { + {"rounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.rounding; }}, + {"bordersize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.borderSize; }}, + }; bool m_bWantsMonitorReload = false; bool m_bForceReload = false; diff --git a/src/config/ConfigValue.hpp b/src/config/ConfigValue.hpp index fc8abb4b..181fdd0f 100644 --- a/src/config/ConfigValue.hpp +++ b/src/config/ConfigValue.hpp @@ -13,6 +13,7 @@ class CConfigValue { CConfigValue(const std::string& val) { const auto PVHYPRLANG = g_pConfigManager->getHyprlangConfigValuePtr(val); + // NOLINTNEXTLINE p_ = PVHYPRLANG->getDataStaticPtr(); #ifdef HYPRLAND_DEBUG |
