core: move parts of the animation system to hyprutils (#8868)
* core: change animation manager to use Hyprutils::Animation
* config: move animation config to hyprutils animation tree
* use g_pAnimationManager->createAnimation and the new PHLANIMVAR template
* core: use CGenericAnimatedVariabled::{enabled,setConfig,getStyle} and adapt callbacks
* core: adapt animated variable usage (dereference the shared pointer)
* misc: bump CMakeLists to hyprutils 0.3.3
This commit is contained in:
parent
c7086f936a
commit
5642ed331d
44 changed files with 1031 additions and 1664 deletions
|
|
@ -11,6 +11,7 @@
|
|||
#include "../protocols/LayerShell.hpp"
|
||||
#include "../xwayland/XWayland.hpp"
|
||||
#include "../protocols/OutputManagement.hpp"
|
||||
#include "managers/AnimationManager.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
|
@ -32,6 +33,7 @@
|
|||
#include <hyprutils/string/String.hpp>
|
||||
#include <filesystem>
|
||||
using namespace Hyprutils::String;
|
||||
using namespace Hyprutils::Animation;
|
||||
|
||||
//NOLINTNEXTLINE
|
||||
extern "C" char** environ;
|
||||
|
|
@ -681,7 +683,6 @@ CConfigManager::CConfigManager() {
|
|||
|
||||
m_pConfig->commence();
|
||||
|
||||
setDefaultAnimationVars();
|
||||
resetHLConfig();
|
||||
|
||||
Debug::log(INFO,
|
||||
|
|
@ -780,76 +781,46 @@ void CConfigManager::reload() {
|
|||
}
|
||||
|
||||
void CConfigManager::setDefaultAnimationVars() {
|
||||
if (isFirstLaunch) {
|
||||
INITANIMCFG("__internal_fadeCTM");
|
||||
m_AnimationTree.createNode("__internal_fadeCTM");
|
||||
m_AnimationTree.createNode("global");
|
||||
|
||||
INITANIMCFG("global");
|
||||
INITANIMCFG("windows");
|
||||
INITANIMCFG("layers");
|
||||
INITANIMCFG("fade");
|
||||
INITANIMCFG("border");
|
||||
INITANIMCFG("borderangle");
|
||||
// global
|
||||
m_AnimationTree.createNode("windows", "global");
|
||||
m_AnimationTree.createNode("layers", "global");
|
||||
m_AnimationTree.createNode("fade", "global");
|
||||
m_AnimationTree.createNode("border", "global");
|
||||
m_AnimationTree.createNode("borderangle", "global");
|
||||
m_AnimationTree.createNode("workspaces", "global");
|
||||
|
||||
// windows
|
||||
INITANIMCFG("windowsIn");
|
||||
INITANIMCFG("windowsOut");
|
||||
INITANIMCFG("windowsMove");
|
||||
// layer
|
||||
m_AnimationTree.createNode("layersIn", "layers");
|
||||
m_AnimationTree.createNode("layersOut", "layers");
|
||||
|
||||
// layers
|
||||
INITANIMCFG("layersIn");
|
||||
INITANIMCFG("layersOut");
|
||||
// windows
|
||||
m_AnimationTree.createNode("windowsIn", "windows");
|
||||
m_AnimationTree.createNode("windowsOut", "windows");
|
||||
m_AnimationTree.createNode("windowsMove", "windows");
|
||||
|
||||
// fade
|
||||
INITANIMCFG("fadeIn");
|
||||
INITANIMCFG("fadeOut");
|
||||
INITANIMCFG("fadeSwitch");
|
||||
INITANIMCFG("fadeShadow");
|
||||
INITANIMCFG("fadeDim");
|
||||
// fade
|
||||
m_AnimationTree.createNode("fadeIn", "fade");
|
||||
m_AnimationTree.createNode("fadeOut", "fade");
|
||||
m_AnimationTree.createNode("fadeSwitch", "fade");
|
||||
m_AnimationTree.createNode("fadeShadow", "fade");
|
||||
m_AnimationTree.createNode("fadeDim", "fade");
|
||||
m_AnimationTree.createNode("fadeLayers", "fade");
|
||||
m_AnimationTree.createNode("fadeLayersIn", "fadeLayers");
|
||||
m_AnimationTree.createNode("fadeLayersOut", "fadeLayers");
|
||||
|
||||
// border
|
||||
// workspaces
|
||||
m_AnimationTree.createNode("workspacesIn", "workspaces");
|
||||
m_AnimationTree.createNode("workspacesOut", "workspaces");
|
||||
m_AnimationTree.createNode("specialWorkspace", "workspaces");
|
||||
m_AnimationTree.createNode("specialWorkspaceIn", "specialWorkspace");
|
||||
m_AnimationTree.createNode("specialWorkspaceOut", "specialWorkspace");
|
||||
|
||||
// workspaces
|
||||
INITANIMCFG("workspaces");
|
||||
INITANIMCFG("workspacesIn");
|
||||
INITANIMCFG("workspacesOut");
|
||||
INITANIMCFG("specialWorkspace");
|
||||
INITANIMCFG("specialWorkspaceIn");
|
||||
INITANIMCFG("specialWorkspaceOut");
|
||||
}
|
||||
|
||||
// init the values
|
||||
animationConfig["global"] = {false, "default", "", 8.f, 1, &animationConfig["general"], nullptr};
|
||||
|
||||
animationConfig["__internal_fadeCTM"] = {false, "linear", "", 5.F, 1, &animationConfig["__internal_fadeCTM"], nullptr};
|
||||
|
||||
CREATEANIMCFG("windows", "global");
|
||||
CREATEANIMCFG("layers", "global");
|
||||
CREATEANIMCFG("fade", "global");
|
||||
CREATEANIMCFG("border", "global");
|
||||
CREATEANIMCFG("borderangle", "global");
|
||||
CREATEANIMCFG("workspaces", "global");
|
||||
|
||||
CREATEANIMCFG("layersIn", "layers");
|
||||
CREATEANIMCFG("layersOut", "layers");
|
||||
|
||||
CREATEANIMCFG("windowsIn", "windows");
|
||||
CREATEANIMCFG("windowsOut", "windows");
|
||||
CREATEANIMCFG("windowsMove", "windows");
|
||||
|
||||
CREATEANIMCFG("fadeIn", "fade");
|
||||
CREATEANIMCFG("fadeOut", "fade");
|
||||
CREATEANIMCFG("fadeSwitch", "fade");
|
||||
CREATEANIMCFG("fadeShadow", "fade");
|
||||
CREATEANIMCFG("fadeDim", "fade");
|
||||
CREATEANIMCFG("fadeLayers", "fade");
|
||||
CREATEANIMCFG("fadeLayersIn", "fadeLayers");
|
||||
CREATEANIMCFG("fadeLayersOut", "fadeLayers");
|
||||
|
||||
CREATEANIMCFG("workspacesIn", "workspaces");
|
||||
CREATEANIMCFG("workspacesOut", "workspaces");
|
||||
CREATEANIMCFG("specialWorkspace", "workspaces");
|
||||
CREATEANIMCFG("specialWorkspaceIn", "specialWorkspace");
|
||||
CREATEANIMCFG("specialWorkspaceOut", "specialWorkspace");
|
||||
// init the root nodes
|
||||
m_AnimationTree.setConfigForNode("global", 1, 8.f, "", "default");
|
||||
m_AnimationTree.setConfigForNode("__internal_fadeCTM", 1, 5.f, "", "linear");
|
||||
}
|
||||
|
||||
std::optional<std::string> CConfigManager::resetHLConfig() {
|
||||
|
|
@ -857,6 +828,8 @@ std::optional<std::string> CConfigManager::resetHLConfig() {
|
|||
m_vWindowRules.clear();
|
||||
g_pKeybindManager->clearKeybinds();
|
||||
g_pAnimationManager->removeAllBeziers();
|
||||
g_pAnimationManager->addBezierWithName("linear", Vector2D(0.0, 0.0), Vector2D(1.0, 1.0));
|
||||
|
||||
m_mAdditionalReservedAreas.clear();
|
||||
m_dBlurLSNamespaces.clear();
|
||||
m_vWorkspaceRules.clear();
|
||||
|
|
@ -1647,8 +1620,8 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) {
|
|||
}
|
||||
}
|
||||
|
||||
SAnimationPropertyConfig* CConfigManager::getAnimationPropertyConfig(const std::string& name) {
|
||||
return &animationConfig[name];
|
||||
SP<SAnimationPropertyConfig> CConfigManager::getAnimationPropertyConfig(const std::string& name) {
|
||||
return m_AnimationTree.getConfig(name);
|
||||
}
|
||||
|
||||
void CConfigManager::addParseError(const std::string& err) {
|
||||
|
|
@ -1711,8 +1684,8 @@ ICustomConfigValueData::~ICustomConfigValueData() {
|
|||
; // empty
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, SAnimationPropertyConfig> CConfigManager::getAnimationConfig() {
|
||||
return animationConfig;
|
||||
const std::unordered_map<std::string, SP<SAnimationPropertyConfig>>& CConfigManager::getAnimationConfig() {
|
||||
return m_AnimationTree.getFullConfig();
|
||||
}
|
||||
|
||||
void CConfigManager::addPluginConfigVar(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value) {
|
||||
|
|
@ -2058,17 +2031,6 @@ std::optional<std::string> CConfigManager::handleBezier(const std::string& comma
|
|||
return {};
|
||||
}
|
||||
|
||||
void CConfigManager::setAnimForChildren(SAnimationPropertyConfig* const ANIM) {
|
||||
for (auto& [name, anim] : animationConfig) {
|
||||
if (anim.pParentAnimation == ANIM && !anim.overridden) {
|
||||
// if a child isnt overridden, set the values of the parent
|
||||
anim.pValues = ANIM->pValues;
|
||||
|
||||
setAnimForChildren(&anim);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
std::optional<std::string> CConfigManager::handleAnimation(const std::string& command, const std::string& args) {
|
||||
const auto ARGS = CVarList(args);
|
||||
|
||||
|
|
@ -2077,14 +2039,9 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
|
|||
// anim name
|
||||
const auto ANIMNAME = ARGS[0];
|
||||
|
||||
const auto PANIM = animationConfig.find(ANIMNAME);
|
||||
|
||||
if (PANIM == animationConfig.end())
|
||||
if (!m_AnimationTree.nodeExists(ANIMNAME))
|
||||
return "no such animation";
|
||||
|
||||
PANIM->second.overridden = true;
|
||||
PANIM->second.pValues = &PANIM->second;
|
||||
|
||||
// This helper casts strings like "1", "true", "off", "yes"... to int.
|
||||
int64_t enabledInt = configStringToInt(ARGS[1]).value_or(0) == 1;
|
||||
|
||||
|
|
@ -2092,33 +2049,31 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
|
|||
if (enabledInt != 0 && enabledInt != 1)
|
||||
return "invalid animation on/off state";
|
||||
|
||||
PANIM->second.internalEnabled = configStringToInt(ARGS[1]).value_or(0) == 1;
|
||||
if (enabledInt) {
|
||||
int64_t speed = -1;
|
||||
|
||||
if (PANIM->second.internalEnabled) {
|
||||
// speed
|
||||
if (isNumber(ARGS[2], true)) {
|
||||
PANIM->second.internalSpeed = std::stof(ARGS[2]);
|
||||
speed = std::stof(ARGS[2]);
|
||||
|
||||
if (PANIM->second.internalSpeed <= 0) {
|
||||
PANIM->second.internalSpeed = 1.f;
|
||||
if (speed <= 0) {
|
||||
speed = 1.f;
|
||||
return "invalid speed";
|
||||
}
|
||||
} else {
|
||||
PANIM->second.internalSpeed = 10.f;
|
||||
speed = 10.f;
|
||||
return "invalid speed";
|
||||
}
|
||||
|
||||
// curve
|
||||
PANIM->second.internalBezier = ARGS[3];
|
||||
std::string bezierName = ARGS[3];
|
||||
m_AnimationTree.setConfigForNode(ANIMNAME, enabledInt, speed, ARGS[3], ARGS[4]);
|
||||
|
||||
if (!g_pAnimationManager->bezierExists(ARGS[3])) {
|
||||
PANIM->second.internalBezier = "default";
|
||||
if (!g_pAnimationManager->bezierExists(bezierName)) {
|
||||
const auto PANIMNODE = m_AnimationTree.getConfig(ANIMNAME);
|
||||
PANIMNODE->internalBezier = "default";
|
||||
return "no such bezier";
|
||||
}
|
||||
|
||||
// style
|
||||
PANIM->second.internalStyle = ARGS[4];
|
||||
|
||||
if (ARGS[4] != "") {
|
||||
auto ERR = g_pAnimationManager->styleValidInConfigVar(ANIMNAME, ARGS[4]);
|
||||
|
||||
|
|
@ -2127,9 +2082,6 @@ std::optional<std::string> CConfigManager::handleAnimation(const std::string& co
|
|||
}
|
||||
}
|
||||
|
||||
// now, check for children, recursively
|
||||
setAnimForChildren(&PANIM->second);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <hyprutils/animation/AnimationConfig.hpp>
|
||||
#define CONFIG_MANAGER_H
|
||||
|
||||
#include <map>
|
||||
|
|
@ -23,9 +24,6 @@
|
|||
|
||||
#include <hyprlang.hpp>
|
||||
|
||||
#define INITANIMCFG(name) animationConfig[name] = {}
|
||||
#define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
|
||||
|
||||
#define HANDLE void*
|
||||
|
||||
struct SWorkspaceRule {
|
||||
|
|
@ -54,18 +52,6 @@ struct SMonitorAdditionalReservedArea {
|
|||
int right = 0;
|
||||
};
|
||||
|
||||
struct SAnimationPropertyConfig {
|
||||
bool overridden = true;
|
||||
|
||||
std::string internalBezier = "";
|
||||
std::string internalStyle = "";
|
||||
float internalSpeed = 0.f;
|
||||
int internalEnabled = -1;
|
||||
|
||||
SAnimationPropertyConfig* pValues = nullptr;
|
||||
SAnimationPropertyConfig* pParentAnimation = nullptr;
|
||||
};
|
||||
|
||||
struct SPluginKeyword {
|
||||
HANDLE handle = nullptr;
|
||||
std::string name = "";
|
||||
|
|
@ -181,32 +167,32 @@ class CConfigManager {
|
|||
|
||||
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
|
||||
|
||||
std::unordered_map<std::string, SAnimationPropertyConfig> getAnimationConfig();
|
||||
const std::unordered_map<std::string, SP<Hyprutils::Animation::SAnimationPropertyConfig>>& getAnimationConfig();
|
||||
|
||||
void addPluginConfigVar(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value);
|
||||
void addPluginConfigVar(HANDLE handle, const std::string& name, const Hyprlang::CConfigValue& value);
|
||||
void addPluginKeyword(HANDLE handle, const std::string& name, Hyprlang::PCONFIGHANDLERFUNC fun, Hyprlang::SHandlerOptions opts = {});
|
||||
void removePluginConfig(HANDLE handle);
|
||||
|
||||
// no-op when done.
|
||||
void dispatchExecOnce();
|
||||
void dispatchExecShutdown();
|
||||
void dispatchExecOnce();
|
||||
void dispatchExecShutdown();
|
||||
|
||||
void performMonitorReload();
|
||||
void ensureMonitorStatus();
|
||||
void ensureVRR(PHLMONITOR pMonitor = nullptr);
|
||||
void performMonitorReload();
|
||||
void ensureMonitorStatus();
|
||||
void ensureVRR(PHLMONITOR pMonitor = nullptr);
|
||||
|
||||
bool shouldUseSoftwareCursors();
|
||||
bool shouldUseSoftwareCursors();
|
||||
|
||||
std::string parseKeyword(const std::string&, const std::string&);
|
||||
std::string parseKeyword(const std::string&, const std::string&);
|
||||
|
||||
void addParseError(const std::string&);
|
||||
void addParseError(const std::string&);
|
||||
|
||||
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
|
||||
SP<Hyprutils::Animation::SAnimationPropertyConfig> getAnimationPropertyConfig(const std::string&);
|
||||
|
||||
void addExecRule(const SExecRequestedRule&);
|
||||
void addExecRule(const SExecRequestedRule&);
|
||||
|
||||
void handlePluginLoads();
|
||||
std::string getErrors();
|
||||
void handlePluginLoads();
|
||||
std::string getErrors();
|
||||
|
||||
// keywords
|
||||
std::optional<std::string> handleRawExec(const std::string&, const std::string&);
|
||||
|
|
@ -269,39 +255,38 @@ class CConfigManager {
|
|||
bool isLaunchingExecOnce = false; // For exec-once to skip initial ws tracking
|
||||
|
||||
private:
|
||||
std::unique_ptr<Hyprlang::CConfig> m_pConfig;
|
||||
std::unique_ptr<Hyprlang::CConfig> m_pConfig;
|
||||
|
||||
std::vector<std::string> configPaths; // stores all the config paths
|
||||
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
|
||||
std::vector<std::string> configPaths; // stores all the config paths
|
||||
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
|
||||
|
||||
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values
|
||||
Hyprutils::Animation::CAnimationConfigTree m_AnimationTree;
|
||||
|
||||
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
|
||||
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
|
||||
|
||||
std::vector<SExecRequestedRule> execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty
|
||||
std::vector<SExecRequestedRule> execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty
|
||||
|
||||
std::vector<std::string> m_vDeclaredPlugins;
|
||||
std::vector<SPluginKeyword> pluginKeywords;
|
||||
std::vector<SPluginVariable> pluginVariables;
|
||||
std::vector<std::string> m_vDeclaredPlugins;
|
||||
std::vector<SPluginKeyword> pluginKeywords;
|
||||
std::vector<SPluginVariable> pluginVariables;
|
||||
|
||||
bool isFirstLaunch = true; // For exec-once
|
||||
bool isFirstLaunch = true; // For exec-once
|
||||
|
||||
std::vector<SMonitorRule> m_vMonitorRules;
|
||||
std::vector<SWorkspaceRule> m_vWorkspaceRules;
|
||||
std::vector<SP<CWindowRule>> m_vWindowRules;
|
||||
std::vector<SP<CLayerRule>> m_vLayerRules;
|
||||
std::vector<std::string> m_dBlurLSNamespaces;
|
||||
std::vector<SMonitorRule> m_vMonitorRules;
|
||||
std::vector<SWorkspaceRule> m_vWorkspaceRules;
|
||||
std::vector<SP<CWindowRule>> m_vWindowRules;
|
||||
std::vector<SP<CLayerRule>> m_vLayerRules;
|
||||
std::vector<std::string> m_dBlurLSNamespaces;
|
||||
|
||||
bool firstExecDispatched = false;
|
||||
bool m_bManualCrashInitiated = false;
|
||||
std::vector<std::string> firstExecRequests;
|
||||
std::vector<std::string> finalExecRequests;
|
||||
bool firstExecDispatched = false;
|
||||
bool m_bManualCrashInitiated = false;
|
||||
std::vector<std::string> firstExecRequests;
|
||||
std::vector<std::string> finalExecRequests;
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins
|
||||
std::string m_szConfigErrors = "";
|
||||
std::vector<std::pair<std::string, std::string>> m_vFailedPluginConfigValues; // for plugin values of unloaded plugins
|
||||
std::string m_szConfigErrors = "";
|
||||
|
||||
// internal methods
|
||||
void setAnimForChildren(SAnimationPropertyConfig* const);
|
||||
void updateBlurredLS(const std::string&, const bool);
|
||||
void setDefaultAnimationVars();
|
||||
std::optional<std::string> resetHLConfig();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue