core: cleanup window properties
they don't need to be in CConfigManager, and belong to window instead
This commit is contained in:
parent
2acbb59bf2
commit
2c78867a98
5 changed files with 76 additions and 73 deletions
|
|
@ -204,66 +204,33 @@ class CConfigManager {
|
||||||
std::string getErrors();
|
std::string getErrors();
|
||||||
|
|
||||||
// keywords
|
// keywords
|
||||||
std::optional<std::string> handleRawExec(const std::string&, const std::string&);
|
std::optional<std::string> handleRawExec(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleExec(const std::string&, const std::string&);
|
std::optional<std::string> handleExec(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleExecOnce(const std::string&, const std::string&);
|
std::optional<std::string> handleExecOnce(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleExecRawOnce(const std::string&, const std::string&);
|
std::optional<std::string> handleExecRawOnce(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleExecShutdown(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> handleMonitor(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleBind(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> handleUnbind(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleWindowRule(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> handleLayerRule(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleWindowRuleV2(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> handleWorkspaceRules(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleBezier(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> handleAnimation(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleSource(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> handleSubmap(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleBlurLS(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> handleBindWS(const std::string&, const std::string&);
|
||||||
std::optional<std::string> handleEnv(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::optional<std::string> handlePlugin(const std::string&, const std::string&);
|
||||||
|
|
||||||
std::string configCurrentPath;
|
std::string configCurrentPath;
|
||||||
|
|
||||||
std::unordered_map<std::string, std::function<CWindowOverridableVar<bool>*(const PHLWINDOW&)>> mbWindowProperties = {
|
bool m_bWantsMonitorReload = false;
|
||||||
{"allowsinput", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.allowsInput; }},
|
bool m_bNoMonitorReload = false;
|
||||||
{"dimaround", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.dimAround; }},
|
bool isLaunchingExecOnce = false; // For exec-once to skip initial ws tracking
|
||||||
{"decorate", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.decorate; }},
|
bool m_bLastConfigVerificationWasSuccessful = true;
|
||||||
{"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>*(const PHLWINDOW&)>> miWindowProperties = {
|
|
||||||
{"rounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.rounding; }},
|
|
||||||
{"bordersize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.borderSize; }},
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unordered_map<std::string, std::function<CWindowOverridableVar<float>*(PHLWINDOW)>> mfWindowProperties = {
|
|
||||||
{"roundingpower", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.roundingPower; }},
|
|
||||||
{"scrollmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollMouse; }},
|
|
||||||
{"scrolltouchpad", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollTouchpad; }}};
|
|
||||||
|
|
||||||
bool m_bWantsMonitorReload = false;
|
|
||||||
bool m_bNoMonitorReload = false;
|
|
||||||
bool isLaunchingExecOnce = false; // For exec-once to skip initial ws tracking
|
|
||||||
bool m_bLastConfigVerificationWasSuccessful = true;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UP<Hyprlang::CConfig> m_pConfig;
|
UP<Hyprlang::CConfig> m_pConfig;
|
||||||
|
|
|
||||||
|
|
@ -777,15 +777,15 @@ void CWindow::applyDynamicRule(const SP<CWindowRule>& r) {
|
||||||
}
|
}
|
||||||
case CWindowRule::RULE_PROP: {
|
case CWindowRule::RULE_PROP: {
|
||||||
const CVarList VARS(r->szRule, 0, ' ');
|
const CVarList VARS(r->szRule, 0, ' ');
|
||||||
if (auto search = g_pConfigManager->miWindowProperties.find(VARS[1]); search != g_pConfigManager->miWindowProperties.end()) {
|
if (auto search = NWindowProperties::intWindowProperties.find(VARS[1]); search != NWindowProperties::intWindowProperties.end()) {
|
||||||
try {
|
try {
|
||||||
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(std::stoi(VARS[2]), priority);
|
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(std::stoi(VARS[2]), priority);
|
||||||
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->szRule, e.what()); }
|
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->szRule, e.what()); }
|
||||||
} else if (auto search = g_pConfigManager->mfWindowProperties.find(VARS[1]); search != g_pConfigManager->mfWindowProperties.end()) {
|
} else if (auto search = NWindowProperties::floatWindowProperties.find(VARS[1]); search != NWindowProperties::floatWindowProperties.end()) {
|
||||||
try {
|
try {
|
||||||
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(std::stof(VARS[2]), priority);
|
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(std::stof(VARS[2]), priority);
|
||||||
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->szRule, e.what()); }
|
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->szRule, e.what()); }
|
||||||
} else if (auto search = g_pConfigManager->mbWindowProperties.find(VARS[1]); search != g_pConfigManager->mbWindowProperties.end()) {
|
} else if (auto search = NWindowProperties::boolWindowProperties.find(VARS[1]); search != NWindowProperties::boolWindowProperties.end()) {
|
||||||
try {
|
try {
|
||||||
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(VARS[2].empty() ? true : (bool)std::stoi(VARS[2]), priority);
|
*(search->second(m_pSelf.lock())) = CWindowOverridableVar(VARS[2].empty() ? true : (bool)std::stoi(VARS[2]), priority);
|
||||||
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->szRule, e.what()); }
|
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->szRule, e.what()); }
|
||||||
|
|
@ -1653,13 +1653,13 @@ PHLWINDOW CWindow::getSwallower() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindow::unsetWindowData(eOverridePriority priority) {
|
void CWindow::unsetWindowData(eOverridePriority priority) {
|
||||||
for (auto const& element : g_pConfigManager->mbWindowProperties) {
|
for (auto const& element : NWindowProperties::boolWindowProperties) {
|
||||||
element.second(m_pSelf.lock())->unset(priority);
|
element.second(m_pSelf.lock())->unset(priority);
|
||||||
}
|
}
|
||||||
for (auto const& element : g_pConfigManager->miWindowProperties) {
|
for (auto const& element : NWindowProperties::intWindowProperties) {
|
||||||
element.second(m_pSelf.lock())->unset(priority);
|
element.second(m_pSelf.lock())->unset(priority);
|
||||||
}
|
}
|
||||||
for (auto const& element : g_pConfigManager->mfWindowProperties) {
|
for (auto const& element : NWindowProperties::floatWindowProperties) {
|
||||||
element.second(m_pSelf.lock())->unset(priority);
|
element.second(m_pSelf.lock())->unset(priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -540,6 +540,42 @@ inline bool validMapped(PHLWINDOWREF w) {
|
||||||
return w->m_bIsMapped;
|
return w->m_bIsMapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace NWindowProperties {
|
||||||
|
static const std::unordered_map<std::string, std::function<CWindowOverridableVar<bool>*(const PHLWINDOW&)>> boolWindowProperties = {
|
||||||
|
{"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; }},
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::unordered_map<std::string, std::function<CWindowOverridableVar<int>*(const PHLWINDOW&)>> intWindowProperties = {
|
||||||
|
{"rounding", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.rounding; }},
|
||||||
|
{"bordersize", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.borderSize; }},
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::unordered_map<std::string, std::function<CWindowOverridableVar<float>*(PHLWINDOW)>> floatWindowProperties = {
|
||||||
|
{"roundingpower", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.roundingPower; }},
|
||||||
|
{"scrollmouse", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollMouse; }},
|
||||||
|
{"scrolltouchpad", [](const PHLWINDOW& pWindow) { return &pWindow->m_sWindowData.scrollTouchpad; }},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
format specification
|
format specification
|
||||||
- 'x', only address, equivalent of (uintpr_t)CWindow*
|
- 'x', only address, equivalent of (uintpr_t)CWindow*
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ static const auto RULES_PREFIX = std::unordered_set<std::string>{
|
||||||
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : szValue(value), szRule(rule), v2(isV2), execRule(isExecRule) {
|
CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool isV2, bool isExecRule) : szValue(value), szRule(rule), v2(isV2), execRule(isExecRule) {
|
||||||
const auto VALS = CVarList(rule, 2, ' ');
|
const auto VALS = CVarList(rule, 2, ' ');
|
||||||
const bool VALID = RULES.contains(rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule](auto prefix) { return rule.starts_with(prefix); }) ||
|
const bool VALID = RULES.contains(rule) || std::any_of(RULES_PREFIX.begin(), RULES_PREFIX.end(), [&rule](auto prefix) { return rule.starts_with(prefix); }) ||
|
||||||
(g_pConfigManager->mbWindowProperties.find(VALS[0]) != g_pConfigManager->mbWindowProperties.end()) ||
|
(NWindowProperties::boolWindowProperties.find(VALS[0]) != NWindowProperties::boolWindowProperties.end()) ||
|
||||||
(g_pConfigManager->miWindowProperties.find(VALS[0]) != g_pConfigManager->miWindowProperties.end()) ||
|
(NWindowProperties::intWindowProperties.find(VALS[0]) != NWindowProperties::intWindowProperties.end()) ||
|
||||||
(g_pConfigManager->mfWindowProperties.find(VALS[0]) != g_pConfigManager->mfWindowProperties.end());
|
(NWindowProperties::floatWindowProperties.find(VALS[0]) != NWindowProperties::floatWindowProperties.end());
|
||||||
|
|
||||||
if (!VALID)
|
if (!VALID)
|
||||||
return;
|
return;
|
||||||
|
|
@ -80,9 +80,9 @@ CWindowRule::CWindowRule(const std::string& rule, const std::string& value, bool
|
||||||
else {
|
else {
|
||||||
// check if this is a prop.
|
// check if this is a prop.
|
||||||
const CVarList VARS(rule, 0, 's', true);
|
const CVarList VARS(rule, 0, 's', true);
|
||||||
if (g_pConfigManager->miWindowProperties.find(VARS[0]) != g_pConfigManager->miWindowProperties.end() ||
|
if (NWindowProperties::intWindowProperties.find(VARS[0]) != NWindowProperties::intWindowProperties.end() ||
|
||||||
g_pConfigManager->mbWindowProperties.find(VARS[0]) != g_pConfigManager->mbWindowProperties.end() ||
|
NWindowProperties::boolWindowProperties.find(VARS[0]) != NWindowProperties::boolWindowProperties.end() ||
|
||||||
g_pConfigManager->mfWindowProperties.find(VARS[0]) != g_pConfigManager->mfWindowProperties.end()) {
|
NWindowProperties::floatWindowProperties.find(VARS[0]) != NWindowProperties::floatWindowProperties.end()) {
|
||||||
*const_cast<std::string*>(&szRule) = "prop " + rule;
|
*const_cast<std::string*>(&szRule) = "prop " + rule;
|
||||||
ruleType = RULE_PROP;
|
ruleType = RULE_PROP;
|
||||||
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, szRule);
|
Debug::log(LOG, "CWindowRule: direct prop rule found, rewritten {} -> {}", rule, szRule);
|
||||||
|
|
|
||||||
|
|
@ -3177,7 +3177,7 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
|
||||||
PWINDOW->m_sWindowData.activeBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP);
|
PWINDOW->m_sWindowData.activeBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP);
|
||||||
else
|
else
|
||||||
PWINDOW->m_sWindowData.inactiveBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP);
|
PWINDOW->m_sWindowData.inactiveBorderColor = CWindowOverridableVar(colorData, PRIORITY_SET_PROP);
|
||||||
} else if (auto search = g_pConfigManager->mbWindowProperties.find(PROP); search != g_pConfigManager->mbWindowProperties.end()) {
|
} else if (auto search = NWindowProperties::boolWindowProperties.find(PROP); search != NWindowProperties::boolWindowProperties.end()) {
|
||||||
auto pWindowDataElement = search->second(PWINDOW);
|
auto pWindowDataElement = search->second(PWINDOW);
|
||||||
if (VAL == "toggle")
|
if (VAL == "toggle")
|
||||||
*pWindowDataElement = CWindowOverridableVar(!pWindowDataElement->valueOrDefault(), PRIORITY_SET_PROP);
|
*pWindowDataElement = CWindowOverridableVar(!pWindowDataElement->valueOrDefault(), PRIORITY_SET_PROP);
|
||||||
|
|
@ -3185,12 +3185,12 @@ SDispatchResult CKeybindManager::setProp(std::string args) {
|
||||||
pWindowDataElement->unset(PRIORITY_SET_PROP);
|
pWindowDataElement->unset(PRIORITY_SET_PROP);
|
||||||
else
|
else
|
||||||
*pWindowDataElement = CWindowOverridableVar((bool)configStringToInt(VAL).value_or(0), 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()) {
|
} else if (auto search = NWindowProperties::intWindowProperties.find(PROP); search != NWindowProperties::intWindowProperties.end()) {
|
||||||
if (VAL == "unset")
|
if (VAL == "unset")
|
||||||
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 if (auto search = g_pConfigManager->mfWindowProperties.find(PROP); search != g_pConfigManager->mfWindowProperties.end()) {
|
} else if (auto search = NWindowProperties::floatWindowProperties.find(PROP); search != NWindowProperties::floatWindowProperties.end()) {
|
||||||
if (VAL == "unset")
|
if (VAL == "unset")
|
||||||
search->second(PWINDOW)->unset(PRIORITY_SET_PROP);
|
search->second(PWINDOW)->unset(PRIORITY_SET_PROP);
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue