config/monitor: allow per-monitor vrr to inherit misc:vrr (#14746)

* config/monitor: allow per-monitor vrr to inherit misc:vrr

Signed-off-by: BlueManCZ <ivo97@centrum.cz>

* keep std::optional<int> for m_vrr

Signed-off-by: BlueManCZ <ivo97@centrum.cz>

---------

Signed-off-by: BlueManCZ <ivo97@centrum.cz>
This commit is contained in:
Ivo Šmerek
2026-05-28 13:55:44 +01:00
committed by GitHub
parent 293aa7c118
commit faecc5950a
4 changed files with 14 additions and 5 deletions
+4 -2
View File
@@ -835,8 +835,10 @@ std::optional<std::string> CConfigManager::handleMonitorv2(const std::string& ou
if (VAL && VAL->m_bSetByUser)
parser.rule().m_sdrSaturation = std::any_cast<Hyprlang::FLOAT>(VAL->getValue());
VAL = m_config->getSpecialConfigValuePtr("monitorv2", "vrr", output.c_str());
if (VAL && VAL->m_bSetByUser)
parser.rule().m_vrr = std::any_cast<Hyprlang::INT>(VAL->getValue());
if (VAL && VAL->m_bSetByUser) {
const auto VRR = sc<int>(std::any_cast<Hyprlang::INT>(VAL->getValue()));
parser.rule().m_vrr = VRR < 0 ? std::nullopt : std::optional(VRR);
}
VAL = m_config->getSpecialConfigValuePtr("monitorv2", "transform", output.c_str());
if (VAL && VAL->m_bSetByUser)
parser.parseTransform(std::any_cast<Hyprlang::STRING>(VAL->getValue()));
@@ -129,9 +129,10 @@ namespace {
p.rule().m_sdrSaturation = *sc<const Config::FLOAT*>(v->data());
return true;
}},
{"vrr", []() -> ILuaConfigValue* { return new CLuaConfigInt(0, 0, 3); },
{"vrr", []() -> ILuaConfigValue* { return new CLuaConfigInt(-1, -1, 3); },
[](ILuaConfigValue* v, CMonitorRuleParser& p) {
p.rule().m_vrr = sc<int>(*sc<const Config::INTEGER*>(v->data()));
const auto VRR = sc<int>(*sc<const Config::INTEGER*>(v->data()));
p.rule().m_vrr = VRR < 0 ? std::nullopt : std::optional(VRR);
return true;
}},
{"icc", []() -> ILuaConfigValue* { return new CLuaConfigString(STRVAL_EMPTY); },
+2 -1
View File
@@ -267,7 +267,8 @@ bool CMonitorRuleParser::parseVRR(const std::string& value) {
return false;
}
m_rule.m_vrr = std::stoi(value);
const auto VRR = std::stoi(value);
m_rule.m_vrr = VRR < 0 ? std::nullopt : std::optional(VRR);
return true;
}
+5
View File
@@ -179,6 +179,11 @@ TEST(Config, monitorParserVRR) {
CMonitorRuleParser p3("DP-1");
EXPECT_FALSE(p3.parseVRR("abc"));
EXPECT_TRUE(p3.getError().has_value());
// -1 clears the per-monitor override so the monitor follows misc:vrr again
CMonitorRuleParser p4("DP-1");
EXPECT_TRUE(p4.parseVRR("-1"));
EXPECT_FALSE(p4.rule().m_vrr.has_value());
}
TEST(Config, monitorParserSDRBrightness) {