mirror of
https://github.com/hyprwm/Hyprland.git
synced 2026-08-24 02:24:14 -05:00
config: fix CONFIG_VALUES not returning proper current values (#15948)
ref #15940
This commit is contained in:
@@ -14,7 +14,21 @@ using namespace Hyprutils::Memory;
|
||||
#define UP CUniquePointer
|
||||
#define SP CSharedPointer
|
||||
|
||||
static std::string getCommandStdOut(std::string command) {
|
||||
static constexpr auto CONFIGURED_DESCRIPTION_VALUES = R"(
|
||||
def matches($name; $default; $current):
|
||||
([.[] | select(.name == $name)] |
|
||||
length == 1 and
|
||||
.[0].default == $default and
|
||||
.[0].current == $current);
|
||||
|
||||
matches("general:border_size"; 1; 2) and
|
||||
matches("general:snap:enabled"; false; true) and
|
||||
matches("decoration:rounding"; 0; 10) and
|
||||
matches("master:new_status"; "slave"; "master") and
|
||||
matches("scrolling:follow_min_visible"; 0.4; 1)
|
||||
)";
|
||||
|
||||
static std::string getCommandStdOut(std::string command) {
|
||||
CProcess process("bash", {"-c", command});
|
||||
process.addEnv("HYPRLAND_INSTANCE_SIGNATURE", HIS);
|
||||
process.runSync();
|
||||
@@ -25,6 +39,13 @@ static std::string getCommandStdOut(std::string command) {
|
||||
return stdOut.substr(0, stdOut.length() - 1);
|
||||
}
|
||||
|
||||
static bool descriptionsMatch(const std::string& filter) {
|
||||
CProcess jqProc("bash", {"-c", std::format("hyprctl descriptions | jq -e '{}'", filter)});
|
||||
jqProc.addEnv("HYPRLAND_INSTANCE_SIGNATURE", HIS);
|
||||
jqProc.runSync();
|
||||
return jqProc.exitCode() == 0;
|
||||
}
|
||||
|
||||
static void setWindowProp(const std::string& selector, const std::string& prop, const std::string& value) {
|
||||
getFromSocket(std::format("/dispatch hl.dsp.window.set_prop({{ window = '{}', prop = '{}', value = '{}' }})", selector, prop, value));
|
||||
}
|
||||
@@ -160,10 +181,31 @@ TEST_CASE(hyprctlSubmap) {
|
||||
}
|
||||
|
||||
TEST_CASE(hyprctlJsonErrors) {
|
||||
CProcess jqProc("bash", {"-c", "hyprctl descriptions | jq"});
|
||||
jqProc.addEnv("HYPRLAND_INSTANCE_SIGNATURE", HIS);
|
||||
jqProc.runSync();
|
||||
EXPECT(jqProc.exitCode(), 0);
|
||||
EXPECT(descriptionsMatch(R"(type == "array")"), true);
|
||||
}
|
||||
|
||||
TEST_CASE(hyprctlDescriptionsCurrentValues) {
|
||||
EXPECT(descriptionsMatch(CONFIGURED_DESCRIPTION_VALUES), true);
|
||||
|
||||
OK(getFromSocket(
|
||||
"/eval hl.config({ general = { border_size = 7, snap = { enabled = false } }, master = { new_status = 'inherit' }, scrolling = { follow_min_visible = 0.625 } })"));
|
||||
|
||||
EXPECT(descriptionsMatch(R"(
|
||||
def matches($name; $default; $current):
|
||||
([.[] | select(.name == $name)] |
|
||||
length == 1 and
|
||||
.[0].default == $default and
|
||||
.[0].current == $current);
|
||||
|
||||
matches("general:border_size"; 1; 7) and
|
||||
matches("general:snap:enabled"; false; false) and
|
||||
matches("master:new_status"; "slave"; "inherit") and
|
||||
matches("scrolling:follow_min_visible"; 0.4; 0.625)
|
||||
)"),
|
||||
true);
|
||||
|
||||
OK(getFromSocket("/reload"));
|
||||
EXPECT(descriptionsMatch(CONFIGURED_DESCRIPTION_VALUES), true);
|
||||
}
|
||||
|
||||
TEST_CASE(hyprctlBindsJson) {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "supplementary/jeremy/Jeremy.hpp"
|
||||
#include "lua/ConfigManager.hpp"
|
||||
#include "../debug/log/Logger.hpp"
|
||||
#include "values/ConfigValues.hpp"
|
||||
|
||||
#include <hyprutils/path/Path.hpp>
|
||||
#include <filesystem>
|
||||
@@ -49,6 +50,10 @@ bool Config::initConfigManager() {
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& v : Values::CONFIG_VALUES) {
|
||||
v->commence();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,4 +66,4 @@ const char* Config::typeToString(eConfigManagerType t) {
|
||||
case CONFIG_LUA: return "lua";
|
||||
default: return "error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ CConfigManager::SDeviceConfig::SDeviceConfig() {
|
||||
|
||||
CConfigManager::CConfigManager() : m_mainConfigPath(Supplementary::Jeremy::getMainConfigPath()->path) {
|
||||
for (const auto& v : Values::CONFIG_VALUES) {
|
||||
m_configValues.emplace(luaConfigValueName(v->name()), fromGenericValue(v));
|
||||
registerValue(luaConfigValueName(v->name()).c_str(), fromGenericValue(v));
|
||||
}
|
||||
|
||||
m_configValues["autogenerated"] = fromGenericValue(makeShared<Values::CIntValue>("autogenerated", "whether the config is autogenerated or not", 0));
|
||||
@@ -495,8 +495,8 @@ eConfigManagerType CConfigManager::type() {
|
||||
return CONFIG_LUA;
|
||||
}
|
||||
|
||||
void CConfigManager::registerValue(const char* name, ILuaConfigValue* val) {
|
||||
m_configValues.emplace(name, UP<ILuaConfigValue>(val));
|
||||
void CConfigManager::registerValue(const char* name, UP<ILuaConfigValue>&& val) {
|
||||
m_configValues.emplace(name, std::move(val));
|
||||
}
|
||||
|
||||
void CConfigManager::cleanTimers() {
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Config::Lua {
|
||||
private:
|
||||
void reinitLuaState();
|
||||
void postConfigReload();
|
||||
void registerValue(const char* name, ILuaConfigValue* val);
|
||||
void registerValue(const char* name, UP<ILuaConfigValue>&& val);
|
||||
void cleanTimers();
|
||||
void clearLuaLayoutProviders();
|
||||
void clearHeldLuaRefs();
|
||||
|
||||
Reference in New Issue
Block a user