diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 4d3c2be4..7c0a9417 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -1529,9 +1529,8 @@ std::string dispatchNotify(eHyprCtlOutputFormat format, std::string request) { icon = std::stoi(ICON); } catch (std::exception& e) { return "invalid arg 1"; } - if (icon > ICON_NONE || icon < 0) { + if (icon > ICON_NONE || icon < 0) icon = ICON_NONE; - } const auto TIME = vars[2]; int time = 0; @@ -1539,7 +1538,10 @@ std::string dispatchNotify(eHyprCtlOutputFormat format, std::string request) { time = std::stoi(TIME); } catch (std::exception& e) { return "invalid arg 2"; } - CColor color = configStringToInt(vars[3]).value_or(0); + const auto COLOR_RESULT = configStringToInt(vars[3]); + if (!COLOR_RESULT) + return "invalid arg 3"; + CColor color = *COLOR_RESULT; size_t msgidx = 4; float fontsize = 13.f; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c9ca90e5..75e2a7b3 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -2920,6 +2920,9 @@ SDispatchResult CKeybindManager::event(std::string args) { return {}; } +#include +#include + SDispatchResult CKeybindManager::setProp(std::string args) { CVarList vars(args, 3, ' '); @@ -2972,14 +2975,17 @@ SDispatchResult CKeybindManager::setProp(std::string args) { const auto TOKEN = vars[i]; if (TOKEN.ends_with("deg")) colorData.m_fAngle = std::stoi(TOKEN.substr(0, TOKEN.size() - 3)) * (PI / 180.0); - else if (const auto V = configStringToInt(TOKEN); V) - colorData.m_vColors.push_back(*V); + else + configStringToInt(TOKEN).and_then([&colorData](const auto& e) { + colorData.m_vColors.push_back(e); + return std::result_of::type(1); + }); } - } else if (VAL != "-1") { - const auto V = configStringToInt(VAL); - if (V) - colorData.m_vColors.push_back(*V); - } + } else if (VAL != "-1") + configStringToInt(VAL).and_then([&colorData](const auto& e) { + colorData.m_vColors.push_back(e); + return std::result_of::type(1); + }); if (PROP == "activebordercolor") PWINDOW->m_sWindowData.activeBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP); @@ -2998,9 +3004,8 @@ SDispatchResult CKeybindManager::setProp(std::string args) { search->second(PWINDOW)->unset(PRIORITY_SET_PROP); else if (const auto V = configStringToInt(VAL); V) *(search->second(PWINDOW)) = CWindowOverridableVar((int)*V, PRIORITY_SET_PROP); - } else { + } else return {.success = false, .error = "Prop not found"}; - } } catch (std::exception& e) { return {.success = false, .error = std::format("Error parsing prop value: {}", std::string(e.what()))}; } g_pCompositor->updateAllWindowsAnimatedDecorationValues();