mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 01:05:58 +01:00
internal: minor cleanups for color results
This commit is contained in:
parent
47a1650c48
commit
67cee43006
2 changed files with 19 additions and 12 deletions
|
@ -1529,9 +1529,8 @@ std::string dispatchNotify(eHyprCtlOutputFormat format, std::string request) {
|
||||||
icon = std::stoi(ICON);
|
icon = std::stoi(ICON);
|
||||||
} catch (std::exception& e) { return "invalid arg 1"; }
|
} catch (std::exception& e) { return "invalid arg 1"; }
|
||||||
|
|
||||||
if (icon > ICON_NONE || icon < 0) {
|
if (icon > ICON_NONE || icon < 0)
|
||||||
icon = ICON_NONE;
|
icon = ICON_NONE;
|
||||||
}
|
|
||||||
|
|
||||||
const auto TIME = vars[2];
|
const auto TIME = vars[2];
|
||||||
int time = 0;
|
int time = 0;
|
||||||
|
@ -1539,7 +1538,10 @@ std::string dispatchNotify(eHyprCtlOutputFormat format, std::string request) {
|
||||||
time = std::stoi(TIME);
|
time = std::stoi(TIME);
|
||||||
} catch (std::exception& e) { return "invalid arg 2"; }
|
} 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;
|
size_t msgidx = 4;
|
||||||
float fontsize = 13.f;
|
float fontsize = 13.f;
|
||||||
|
|
|
@ -2920,6 +2920,9 @@ SDispatchResult CKeybindManager::event(std::string args) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
SDispatchResult CKeybindManager::setProp(std::string args) {
|
SDispatchResult CKeybindManager::setProp(std::string args) {
|
||||||
CVarList vars(args, 3, ' ');
|
CVarList vars(args, 3, ' ');
|
||||||
|
|
||||||
|
@ -2972,14 +2975,17 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
|
||||||
const auto TOKEN = vars[i];
|
const auto TOKEN = vars[i];
|
||||||
if (TOKEN.ends_with("deg"))
|
if (TOKEN.ends_with("deg"))
|
||||||
colorData.m_fAngle = std::stoi(TOKEN.substr(0, TOKEN.size() - 3)) * (PI / 180.0);
|
colorData.m_fAngle = std::stoi(TOKEN.substr(0, TOKEN.size() - 3)) * (PI / 180.0);
|
||||||
else if (const auto V = configStringToInt(TOKEN); V)
|
else
|
||||||
colorData.m_vColors.push_back(*V);
|
configStringToInt(TOKEN).and_then([&colorData](const auto& e) {
|
||||||
|
colorData.m_vColors.push_back(e);
|
||||||
|
return std::result_of<decltype (&configStringToInt)(std::string)>::type(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else if (VAL != "-1") {
|
} else if (VAL != "-1")
|
||||||
const auto V = configStringToInt(VAL);
|
configStringToInt(VAL).and_then([&colorData](const auto& e) {
|
||||||
if (V)
|
colorData.m_vColors.push_back(e);
|
||||||
colorData.m_vColors.push_back(*V);
|
return std::result_of<decltype (&configStringToInt)(std::string)>::type(1);
|
||||||
}
|
});
|
||||||
|
|
||||||
if (PROP == "activebordercolor")
|
if (PROP == "activebordercolor")
|
||||||
PWINDOW->m_sWindowData.activeBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP);
|
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);
|
search->second(PWINDOW)->unset(PRIORITY_SET_PROP);
|
||||||
else if (const auto V = configStringToInt(VAL); V)
|
else if (const auto V = configStringToInt(VAL); V)
|
||||||
*(search->second(PWINDOW)) = CWindowOverridableVar((int)*V, PRIORITY_SET_PROP);
|
*(search->second(PWINDOW)) = CWindowOverridableVar((int)*V, PRIORITY_SET_PROP);
|
||||||
} else {
|
} else
|
||||||
return {.success = false, .error = "Prop not found"};
|
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()))}; }
|
} catch (std::exception& e) { return {.success = false, .error = std::format("Error parsing prop value: {}", std::string(e.what()))}; }
|
||||||
|
|
||||||
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
|
g_pCompositor->updateAllWindowsAnimatedDecorationValues();
|
||||||
|
|
Loading…
Reference in a new issue