mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-02 11:45:58 +01:00
Add hyprctl animations
This commit is contained in:
parent
12e293e309
commit
9813ba2f56
6 changed files with 80 additions and 11 deletions
|
@ -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"))
|
||||
|
|
|
@ -1704,3 +1704,7 @@ void CConfigManager::addExecRule(const SExecRequestedRule& rule) {
|
|||
ICustomConfigValueData::~ICustomConfigValueData() {
|
||||
; // empty
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, SAnimationPropertyConfig> CConfigManager::getAnimationConfig() {
|
||||
return animationConfig;
|
||||
}
|
||||
|
|
|
@ -155,6 +155,8 @@ class CConfigManager {
|
|||
|
||||
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
|
||||
|
||||
std::unordered_map<std::string, SAnimationPropertyConfig> getAnimationConfig();
|
||||
|
||||
// no-op when done.
|
||||
void dispatchExecOnce();
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -464,3 +464,7 @@ CBezierCurve* CAnimationManager::getBezier(const std::string& name) {
|
|||
|
||||
return BEZIER == m_mBezierCurves.end() ? &m_mBezierCurves["default"] : &BEZIER->second;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, CBezierCurve> CAnimationManager::getAllBeziers() {
|
||||
return m_mBezierCurves;
|
||||
}
|
||||
|
|
|
@ -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<CAnimatedVariable*> m_lAnimatedVariables;
|
||||
std::unordered_map<std::string, CBezierCurve> getAllBeziers();
|
||||
|
||||
std::list<CAnimatedVariable*> m_lAnimatedVariables;
|
||||
|
||||
private:
|
||||
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
||||
|
|
Loading…
Reference in a new issue