aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--example/hyprland.conf1
-rw-r--r--src/Compositor.cpp8
-rw-r--r--src/Window.cpp33
-rw-r--r--src/Window.hpp4
-rw-r--r--src/config/ConfigDataValues.hpp7
-rw-r--r--src/config/ConfigManager.cpp2
-rw-r--r--src/config/defaultConfig.hpp1
-rw-r--r--src/helpers/MiscFunctions.cpp16
-rw-r--r--src/helpers/MiscFunctions.hpp2
-rw-r--r--src/managers/AnimationManager.cpp4
-rw-r--r--src/render/Renderer.cpp13
11 files changed, 77 insertions, 14 deletions
diff --git a/example/hyprland.conf b/example/hyprland.conf
index 63268ede..0b72afd9 100644
--- a/example/hyprland.conf
+++ b/example/hyprland.conf
@@ -73,6 +73,7 @@ animations {
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
+ animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
}
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index c2c80aee..af65d561 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -1565,8 +1565,8 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
pWindow->m_cRealBorderColorPrevious = pWindow->m_cRealBorderColor;
pWindow->m_cRealBorderColor = grad;
- pWindow->m_fBorderAnimationProgress.setValueAndWarp(0.f);
- pWindow->m_fBorderAnimationProgress = 1.f;
+ pWindow->m_fBorderFadeAnimationProgress.setValueAndWarp(0.f);
+ pWindow->m_fBorderFadeAnimationProgress = 1.f;
};
// border
@@ -1581,6 +1581,10 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
CGradientValueData(CColor(pWindow->m_sSpecialRenderData.inactiveBorderColor.toUnderlying())) :
*INACTIVECOL));
+ // tick angle if it's not running (aka dead)
+ if (!pWindow->m_fBorderAngleAnimationProgress.isBeingAnimated())
+ pWindow->m_fBorderAngleAnimationProgress.setValueAndWarp(0.f);
+
// opacity
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
if (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
diff --git a/src/Window.cpp b/src/Window.cpp
index c2f75868..3d109667 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -5,7 +5,8 @@
CWindow::CWindow() {
m_vRealPosition.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_vRealSize.create(AVARTYPE_VECTOR, g_pConfigManager->getAnimationPropertyConfig("windowsIn"), (void*)this, AVARDAMAGE_ENTIRE);
- m_fBorderAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER);
+ m_fBorderFadeAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("border"), (void*)this, AVARDAMAGE_BORDER);
+ m_fBorderAngleAnimationProgress.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("borderangle"), (void*)this, AVARDAMAGE_BORDER);
m_fAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), (void*)this, AVARDAMAGE_ENTIRE);
m_fActiveInactiveAlpha.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeSwitch"), (void*)this, AVARDAMAGE_ENTIRE);
m_cRealShadowColor.create(AVARTYPE_COLOR, g_pConfigManager->getAnimationPropertyConfig("fadeShadow"), (void*)this, AVARDAMAGE_SHADOW);
@@ -263,7 +264,8 @@ void CWindow::onUnmap() {
m_vRealPosition.setCallbackOnEnd(unregisterVar);
m_vRealSize.setCallbackOnEnd(unregisterVar);
- m_fBorderAnimationProgress.setCallbackOnEnd(unregisterVar);
+ m_fBorderFadeAnimationProgress.setCallbackOnEnd(unregisterVar);
+ m_fBorderAngleAnimationProgress.setCallbackOnEnd(unregisterVar);
m_fActiveInactiveAlpha.setCallbackOnEnd(unregisterVar);
m_fAlpha.setCallbackOnEnd(unregisterVar);
m_cRealShadowColor.setCallbackOnEnd(unregisterVar);
@@ -279,7 +281,8 @@ void CWindow::onMap() {
// JIC, reset the callbacks. If any are set, we'll make sure they are cleared so we don't accidentally unset them. (In case a window got remapped)
m_vRealPosition.resetAllCallbacks();
m_vRealSize.resetAllCallbacks();
- m_fBorderAnimationProgress.resetAllCallbacks();
+ m_fBorderFadeAnimationProgress.resetAllCallbacks();
+ m_fBorderAngleAnimationProgress.resetAllCallbacks();
m_fActiveInactiveAlpha.resetAllCallbacks();
m_fAlpha.resetAllCallbacks();
m_cRealShadowColor.resetAllCallbacks();
@@ -287,7 +290,8 @@ void CWindow::onMap() {
m_vRealPosition.registerVar();
m_vRealSize.registerVar();
- m_fBorderAnimationProgress.registerVar();
+ m_fBorderFadeAnimationProgress.registerVar();
+ m_fBorderAngleAnimationProgress.registerVar();
m_fActiveInactiveAlpha.registerVar();
m_fAlpha.registerVar();
m_cRealShadowColor.registerVar();
@@ -296,9 +300,30 @@ void CWindow::onMap() {
m_vRealSize.setCallbackOnEnd([&](void* ptr) { g_pHyprOpenGL->onWindowResizeEnd(this); }, false);
m_vRealSize.setCallbackOnBegin([&](void* ptr) { g_pHyprOpenGL->onWindowResizeStart(this); }, false);
+ m_fBorderAngleAnimationProgress.setCallbackOnEnd([&](void* ptr) { onBorderAngleAnimEnd(ptr); }, false);
+
+ m_fBorderAngleAnimationProgress.setValueAndWarp(0.f);
+ m_fBorderAngleAnimationProgress = 1.f;
+
g_pCompositor->m_vWindowFocusHistory.push_back(this);
}
+void CWindow::onBorderAngleAnimEnd(void* ptr) {
+ const auto PANIMVAR = (CAnimatedVariable*)ptr;
+
+ const std::string STYLE = PANIMVAR->getConfig()->pValues->internalStyle;
+
+ if (STYLE != "loop")
+ return;
+
+ PANIMVAR->setCallbackOnEnd(nullptr); // we remove the callback here because otherwise setvalueandwarp will recurse this
+
+ PANIMVAR->setValueAndWarp(0);
+ *PANIMVAR = 1.f;
+
+ PANIMVAR->setCallbackOnEnd([&](void* ptr) { onBorderAngleAnimEnd(ptr); }, false);
+}
+
void CWindow::setHidden(bool hidden) {
m_bHidden = hidden;
diff --git a/src/Window.hpp b/src/Window.hpp
index 8e24bfc9..04be3a27 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -220,7 +220,8 @@ class CWindow {
// Animated border
CGradientValueData m_cRealBorderColor = {0};
CGradientValueData m_cRealBorderColorPrevious = {0};
- CAnimatedVariable m_fBorderAnimationProgress;
+ CAnimatedVariable m_fBorderFadeAnimationProgress;
+ CAnimatedVariable m_fBorderAngleAnimationProgress;
// Fade in-out
CAnimatedVariable m_fAlpha;
@@ -296,6 +297,7 @@ class CWindow {
bool isHidden();
void applyDynamicRule(const SWindowRule& r);
void updateDynamicRules();
+ void onBorderAngleAnimEnd(void* ptr);
private:
// For hidden windows and stuff
diff --git a/src/config/ConfigDataValues.hpp b/src/config/ConfigDataValues.hpp
index c7f7fff8..c8195bbf 100644
--- a/src/config/ConfigDataValues.hpp
+++ b/src/config/ConfigDataValues.hpp
@@ -2,7 +2,8 @@
#include "../defines.hpp"
#include <vector>
-enum eConfigValueDataTypes {
+enum eConfigValueDataTypes
+{
CVD_TYPE_INVALID = -1,
CVD_TYPE_GRADIENT = 0
};
@@ -38,7 +39,7 @@ class CGradientValueData : public ICustomConfigValueData {
float m_fAngle = 0;
bool operator==(const CGradientValueData& other) {
- if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
+ if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
return false;
for (size_t i = 0; i < m_vColors.size(); ++i)
@@ -47,4 +48,4 @@ class CGradientValueData : public ICustomConfigValueData {
return true;
}
-}; \ No newline at end of file
+};
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index a59a788f..07ea3d03 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -220,6 +220,7 @@ void CConfigManager::setDefaultAnimationVars() {
INITANIMCFG("windows");
INITANIMCFG("fade");
INITANIMCFG("border");
+ INITANIMCFG("borderangle");
INITANIMCFG("workspaces");
// windows
@@ -246,6 +247,7 @@ void CConfigManager::setDefaultAnimationVars() {
CREATEANIMCFG("windows", "global");
CREATEANIMCFG("fade", "global");
CREATEANIMCFG("border", "global");
+ CREATEANIMCFG("borderangle", "global");
CREATEANIMCFG("workspaces", "global");
CREATEANIMCFG("windowsIn", "windows");
diff --git a/src/config/defaultConfig.hpp b/src/config/defaultConfig.hpp
index fd77b74b..df043149 100644
--- a/src/config/defaultConfig.hpp
+++ b/src/config/defaultConfig.hpp
@@ -82,6 +82,7 @@ animations {
animation = windows, 1, 7, myBezier
animation = windowsOut, 1, 7, default, popin 80%
animation = border, 1, 10, default
+ animation = borderangle, 1, 8, default
animation = fade, 1, 7, default
animation = workspaces, 1, 6, default
}
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index 1b0f9467..88e6fa51 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -518,3 +518,19 @@ int64_t configStringToInt(const std::string& VALUE) {
}
return std::stoll(VALUE);
}
+
+double normalizeAngleRad(double ang) {
+ if (ang > M_PI * 2) {
+ while (ang > M_PI * 2)
+ ang -= M_PI * 2;
+ return ang;
+ }
+
+ if (ang < 0.0) {
+ while (ang < 0.0)
+ ang += M_PI * 2;
+ return ang;
+ }
+
+ return ang;
+} \ No newline at end of file
diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp
index 36bdc3b7..43cfb944 100644
--- a/src/helpers/MiscFunctions.hpp
+++ b/src/helpers/MiscFunctions.hpp
@@ -20,3 +20,5 @@ int64_t configStringToInt(const std::string&);
float getPlusMinusKeywordResult(std::string in, float relative);
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
+
+double normalizeAngleRad(double ang); \ No newline at end of file
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index 354d88d2..30c77ddd 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -453,6 +453,10 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config,
return "";
return "unknown style";
+ } else if (config == "borderangle") {
+ if (style == "loop" || style == "once")
+ return "";
+ return "unknown style";
} else {
return "animation has no styles";
}
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index f7a15f52..1c540f7b 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -310,17 +310,22 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
rounding *= pMonitor->scale;
auto grad = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor;
- const bool ANIMATED = g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.isBeingAnimated();
- float a1 = renderdata.fadeAlpha * renderdata.alpha * (ANIMATED ? g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl() : 1.f);
+ const bool ANIMATED = g_pHyprOpenGL->m_pCurrentWindow->m_fBorderFadeAnimationProgress.isBeingAnimated();
+ float a1 = renderdata.fadeAlpha * renderdata.alpha * (ANIMATED ? g_pHyprOpenGL->m_pCurrentWindow->m_fBorderFadeAnimationProgress.fl() : 1.f);
- wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h};
+ if (g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAngleAnimationProgress.getConfig()->pValues->internalEnabled) {
+ grad.m_fAngle += g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAngleAnimationProgress.fl() * M_PI * 2;
+ grad.m_fAngle = normalizeAngleRad(grad.m_fAngle);
+ }
+
+ wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h};
scaleBox(&windowBox, pMonitor->scale);
g_pHyprOpenGL->renderBorder(&windowBox, grad, rounding, a1);
if (ANIMATED) {
- float a2 = renderdata.fadeAlpha * renderdata.alpha * (1.f - g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl());
+ float a2 = renderdata.fadeAlpha * renderdata.alpha * (1.f - g_pHyprOpenGL->m_pCurrentWindow->m_fBorderFadeAnimationProgress.fl());
g_pHyprOpenGL->renderBorder(&windowBox, g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColorPrevious, rounding, a2);
}
}