diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 37534329..fd2a5b08 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -341,6 +341,8 @@ int main(int argc, char** argv) { request(fullRequest); else if (fullRequest.contains("/cursorpos")) request(fullRequest); + else if (fullRequest.contains("/animations")) + request(fullRequest); else if (fullRequest.contains("/switchxkblayout")) request(fullRequest, 2); else if (fullRequest.contains("/seterror")) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index b9301531..397ec6c9 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1704,3 +1704,7 @@ void CConfigManager::addExecRule(const SExecRequestedRule& rule) { ICustomConfigValueData::~ICustomConfigValueData() { ; // empty } + +std::unordered_map CConfigManager::getAnimationConfig() { + return animationConfig; +} diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 468851b8..2b8ea8ab 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -155,6 +155,8 @@ class CConfigManager { std::unordered_map m_mAdditionalReservedAreas; + std::unordered_map getAnimationConfig(); + // no-op when done. void dispatchExecOnce(); diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 00a107cf..b88e9b60 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -469,6 +469,59 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) { return result; } +std::string animationsRequest(HyprCtl::eHyprCtlOutputFormat format) { + std::string ret = ""; + if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) { + ret += "animations:\n"; + + for (auto& ac : g_pConfigManager->getAnimationConfig()) { + ret += getFormat("\n\tname: %s\n\t\toverriden: %i\n\t\tbezier: %s\n\t\tenabled: %i\n\t\tspeed: %.2f\n\t\tstyle: %s\n", ac.first.c_str(), (int)ac.second.overriden, + ac.second.internalBezier.c_str(), ac.second.internalEnabled, ac.second.internalSpeed, ac.second.internalStyle.c_str()); + } + + ret += "beziers:\n"; + + for (auto& bz : g_pAnimationManager->getAllBeziers()) { + ret += getFormat("\n\tname: %s\n", bz.first.c_str()); + } + } else { + // json + + ret += "[["; + for (auto& ac : g_pConfigManager->getAnimationConfig()) { + ret += getFormat(R"#( +{ + "name": "%s", + "overriden": %s, + "bezier": "%s", + "enabled": %s, + "speed": %.2f, + "style": "%s" +},)#", + ac.first.c_str(), ac.second.overriden ? "true" : "false", ac.second.internalBezier.c_str(), ac.second.internalEnabled ? "true" : "false", + ac.second.internalSpeed, ac.second.internalStyle.c_str()); + } + + ret[ret.length() - 1] = ']'; + + ret += ",\n["; + + for (auto& bz : g_pAnimationManager->getAllBeziers()) { + ret += getFormat(R"#( +{ + "name": "%s" +},)#", + bz.first.c_str()); + } + + ret.pop_back(); + + ret += "]"; + } + + return ret; +} + std::string bindsRequest(HyprCtl::eHyprCtlOutputFormat format) { std::string ret = ""; if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) { @@ -1074,6 +1127,8 @@ std::string getReply(std::string request) { return cursorPosRequest(format); else if (request == "binds") return bindsRequest(format); + else if (request == "animations") + return animationsRequest(format); else if (request.find("setprop") == 0) return dispatchSetProp(request); else if (request.find("seterror") == 0) diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index ad5185bd..a5330c1e 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -201,8 +201,8 @@ void CAnimationManager::tick() { const auto EXTENTS = PDECO->getWindowDecorationExtents(); wlr_box dmg = {PWINDOW->m_vRealPosition.vec().x - EXTENTS.topLeft.x, PWINDOW->m_vRealPosition.vec().y - EXTENTS.topLeft.y, - PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x, - PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y}; + PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x, + PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y}; if (!*PSHADOWIGNOREWINDOW) { // easy, damage the entire box @@ -463,4 +463,8 @@ CBezierCurve* CAnimationManager::getBezier(const std::string& name) { const auto BEZIER = std::find_if(m_mBezierCurves.begin(), m_mBezierCurves.end(), [&](const auto& other) { return other.first == name; }); return BEZIER == m_mBezierCurves.end() ? &m_mBezierCurves["default"] : &BEZIER->second; -} \ No newline at end of file +} + +std::unordered_map CAnimationManager::getAllBeziers() { + return m_mBezierCurves; +} diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp index d08d3395..77e8acf1 100644 --- a/src/managers/AnimationManager.hpp +++ b/src/managers/AnimationManager.hpp @@ -11,18 +11,20 @@ class CAnimationManager { public: CAnimationManager(); - void tick(); - void addBezierWithName(std::string, const Vector2D&, const Vector2D&); - void removeAllBeziers(); + void tick(); + void addBezierWithName(std::string, const Vector2D&, const Vector2D&); + void removeAllBeziers(); - void onWindowPostCreateClose(CWindow*, bool close = false); + void onWindowPostCreateClose(CWindow*, bool close = false); - bool bezierExists(const std::string&); - CBezierCurve* getBezier(const std::string&); + bool bezierExists(const std::string&); + CBezierCurve* getBezier(const std::string&); - std::string styleValidInConfigVar(const std::string&, const std::string&); + std::string styleValidInConfigVar(const std::string&, const std::string&); - std::list m_lAnimatedVariables; + std::unordered_map getAllBeziers(); + + std::list m_lAnimatedVariables; private: bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);