summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-11-20 10:32:50 +0000
committerVaxry <vaxry@vaxry.net>2024-11-20 10:32:50 +0000
commite5fa017172156fa5c70fedeaee5f51eace9577c0 (patch)
tree19a59d9b02f6c50a78446c9c3cb28a4ec464dd26
parentc4eda46d0ef022a17348623beec4154ba34af691 (diff)
internal: fix some misused configStringToInt conversions
fixes #8523
-rw-r--r--src/config/ConfigManager.cpp4
-rw-r--r--src/desktop/Window.cpp2
-rw-r--r--src/desktop/Workspace.cpp4
-rw-r--r--src/managers/KeybindManager.cpp8
4 files changed, 9 insertions, 9 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index fe80a5ab..357e7a60 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -2101,13 +2101,13 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
PANIM->second.pValues = &PANIM->second;
// This helper casts strings like "1", "true", "off", "yes"... to int.
- int64_t enabledInt = configStringToInt(ARGS[1]) == 1;
+ int64_t enabledInt = configStringToInt(ARGS[1]).value_or(0) == 1;
// Checking that the int is 1 or 0 because the helper can return integers out of range.
if (enabledInt != 0 && enabledInt != 1)
return "invalid animation on/off state";
- PANIM->second.internalEnabled = configStringToInt(ARGS[1]) == 1;
+ PANIM->second.internalEnabled = configStringToInt(ARGS[1]).value_or(0) == 1;
if (PANIM->second.internalEnabled) {
// speed
diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp
index 33e6a5f8..117d301c 100644
--- a/src/desktop/Window.cpp
+++ b/src/desktop/Window.cpp
@@ -707,7 +707,7 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(true, priority);
} else {
try {
- *(search->second(m_pSelf.lock())) = CWindowOverridableVar((bool)configStringToInt(VARS[1]), priority);
+ *(search->second(m_pSelf.lock())) = CWindowOverridableVar((bool)configStringToInt(VARS[1]).value_or(0), priority);
} catch (...) {}
}
} else if (auto search = g_pConfigManager->miWindowProperties.find(VARS[0]); search != g_pConfigManager->miWindowProperties.end()) {
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index 2e1e91f2..8cddbb6b 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -332,7 +332,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto SHOULDBESPECIAL = configStringToInt(prop);
- if ((bool)SHOULDBESPECIAL != m_bIsSpecialWorkspace)
+ if (SHOULDBESPECIAL && (bool)*SHOULDBESPECIAL != m_bIsSpecialWorkspace)
return false;
continue;
}
@@ -367,7 +367,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
const auto WANTSNAMED = configStringToInt(prop);
- if (WANTSNAMED != (m_iID <= -1337))
+ if (WANTSNAMED && *WANTSNAMED != (m_iID <= -1337))
return false;
continue;
}
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 75e2a7b3..be1e9534 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -2961,13 +2961,13 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
CWindowOverridableVar(SAlphaValue{std::stof(VAL), PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_bOverride}, PRIORITY_SET_PROP);
} else if (PROP == "alphaoverride") {
PWINDOW->m_sWindowData.alpha =
- CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alpha.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP);
+ CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alpha.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP);
} else if (PROP == "alphainactiveoverride") {
PWINDOW->m_sWindowData.alphaInactive =
- CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaInactive.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP);
+ CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaInactive.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP);
} else if (PROP == "alphafullscreenoverride") {
PWINDOW->m_sWindowData.alphaFullscreen =
- CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL)}, PRIORITY_SET_PROP);
+ CWindowOverridableVar(SAlphaValue{PWINDOW->m_sWindowData.alphaFullscreen.valueOrDefault().m_fAlpha, (bool)configStringToInt(VAL).value_or(0)}, PRIORITY_SET_PROP);
} else if (PROP == "activebordercolor" || PROP == "inactivebordercolor") {
CGradientValueData colorData = {};
if (vars.size() > 4) {
@@ -2998,7 +2998,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
else if (VAL == "unset")
pWindowDataElement->unset(PRIORITY_SET_PROP);
else
- *pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL), PRIORITY_SET_PROP);
+ *pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL).value_or(0), PRIORITY_SET_PROP);
} else if (auto search = g_pConfigManager->miWindowProperties.find(PROP); search != g_pConfigManager->miWindowProperties.end()) {
if (VAL == "unset")
search->second(PWINDOW)->unset(PRIORITY_SET_PROP);