Skip to content

Commit

Permalink
meta: clamp nominalSize
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Dec 21, 2024
1 parent 84203d8 commit abc1c60
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions libhyprcursor/meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <toml++/toml.hpp>
#include <filesystem>
#include <regex>
#include <algorithm>

#include "VarList.hpp"

Expand Down Expand Up @@ -154,7 +155,7 @@ std::optional<std::string> CMeta::parseHL() {

parsedData.hotspotX = std::any_cast<Hyprlang::FLOAT>(meta->getConfigValue("hotspot_x"));
parsedData.hotspotY = std::any_cast<Hyprlang::FLOAT>(meta->getConfigValue("hotspot_y"));
parsedData.nominalSize = std::any_cast<Hyprlang::FLOAT>(meta->getConfigValue("nominal_size"));
parsedData.nominalSize = std::clamp(std::any_cast<Hyprlang::FLOAT>(meta->getConfigValue("nominal_size")), 0.1F, 2.F);
parsedData.resizeAlgo = std::any_cast<Hyprlang::STRING>(meta->getConfigValue("resize_algorithm"));

return {};
Expand All @@ -164,9 +165,9 @@ std::optional<std::string> CMeta::parseTOML() {
try {
auto MANIFEST = dataPath ? toml::parse_file(rawdata) : toml::parse(rawdata);

parsedData.hotspotX = MANIFEST["General"]["hotspot_x"].value_or(0.f);
parsedData.hotspotY = MANIFEST["General"]["hotspot_y"].value_or(0.f);
parsedData.hotspotY = MANIFEST["General"]["nominal_size"].value_or(1.f);
parsedData.hotspotX = MANIFEST["General"]["hotspot_x"].value_or(0.f);
parsedData.hotspotY = MANIFEST["General"]["hotspot_y"].value_or(0.f);
parsedData.nominalSize = std::clamp(MANIFEST["General"]["nominal_size"].value_or(1.F), 0.1F, 2.F);

const std::string OVERRIDES = MANIFEST["General"]["define_override"].value_or("");
const std::string SIZES = MANIFEST["General"]["define_size"].value_or("");
Expand Down

0 comments on commit abc1c60

Please sign in to comment.