hyprctl: make animations print details about bezier curves (#10413) (#10871)

This commit is contained in:
boundlessvoid0
2025-07-16 21:35:15 +02:00
committed by GitHub
parent 148718b3bc
commit 409b56f6a3
2 changed files with 32 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
#include "../../Log.hpp"
#include "tests.hpp"
#include "../../shared.hpp"
#include "../../hyprctlCompat.hpp"
#include <hyprutils/os/Process.hpp>
#include <hyprutils/memory/WeakPtr.hpp>
static int ret = 0;
using namespace Hyprutils::OS;
using namespace Hyprutils::Memory;
static bool test() {
NLog::log("{}Testing animations", Colors::GREEN);
auto str = getFromSocket("/animations");
NLog::log("{}Testing bezier curve output from `hyprctl animations`", Colors::YELLOW);
{EXPECT_CONTAINS(str, std::format("beziers:\n\n\tname: quick\n\t\tX0: 0.15\n\t\tY0: 0.00\n\t\tX1: 0.10\n\t\tY1: 1.00"))};
return !ret;
}
REGISTER_TEST_FN(test)

View File

@@ -786,7 +786,9 @@ static std::string animationsRequest(eHyprCtlOutputFormat format, std::string re
ret += "beziers:\n";
for (auto const& bz : g_pAnimationManager->getAllBeziers()) {
ret += std::format("\n\tname: {}\n", bz.first);
auto& controlPoints = bz.second->getControlPoints();
ret += std::format("\n\tname: {}\n\t\tX0: {:.2f}\n\t\tY0: {:.2f}\n\t\tX1: {:.2f}\n\t\tY1: {:.2f}", bz.first, controlPoints[1].x, controlPoints[1].y, controlPoints[2].x,
controlPoints[2].y);
}
} else {
// json
@@ -811,11 +813,16 @@ static std::string animationsRequest(eHyprCtlOutputFormat format, std::string re
ret += ",\n[";
for (auto const& bz : g_pAnimationManager->getAllBeziers()) {
auto& controlPoints = bz.second->getControlPoints();
ret += std::format(R"#(
{{
"name": "{}"
"name": "{}",
"X0": {:.2f},
"Y0": {:.2f},
"X1": {:.2f},
"Y1": {:.2f}
}},)#",
escapeJSONStrings(bz.first));
escapeJSONStrings(bz.first), controlPoints[1].x, controlPoints[1].y, controlPoints[2].x, controlPoints[2].y);
}
trimTrailingComma(ret);