summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-01-20 20:48:07 +0100
committervaxerski <vaxry@vaxry.net>2023-01-20 20:48:07 +0100
commit5814d9b2a01c9c1d07fef023ad12196d49dd4780 (patch)
treecef3bf60e2961ddf1cd574d773baf7224c2425b8 /src
parent18330dec4e59529c396d3cdadb32fc9bd763f6b2 (diff)
make hyprerror follow fadein anim
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp5
-rw-r--r--src/helpers/AnimatedVariable.hpp6
-rw-r--r--src/hyprerror/HyprError.cpp38
-rw-r--r--src/hyprerror/HyprError.hpp18
-rw-r--r--src/managers/AnimationManager.cpp4
5 files changed, 50 insertions, 21 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 37ec97d5..574c9575 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -306,8 +306,6 @@ void CCompositor::startCompositor() {
// Init all the managers BEFORE we start with the wayland server so that ALL of the stuff is initialized
// properly and we dont get any bad mem reads.
//
- Debug::log(LOG, "Creating the CHyprError!");
- g_pHyprError = std::make_unique<CHyprError>();
Debug::log(LOG, "Creating the KeybindManager!");
g_pKeybindManager = std::make_unique<CKeybindManager>();
@@ -321,6 +319,9 @@ void CCompositor::startCompositor() {
Debug::log(LOG, "Creating the ConfigManager!");
g_pConfigManager = std::make_unique<CConfigManager>();
+ Debug::log(LOG, "Creating the CHyprError!");
+ g_pHyprError = std::make_unique<CHyprError>();
+
Debug::log(LOG, "Creating the ThreadManager!");
g_pThreadManager = std::make_unique<CThreadManager>();
diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp
index b01ca48c..1538b0ce 100644
--- a/src/helpers/AnimatedVariable.hpp
+++ b/src/helpers/AnimatedVariable.hpp
@@ -11,8 +11,8 @@ enum ANIMATEDVARTYPE {
};
enum AVARDAMAGEPOLICY {
- AVARDAMAGE_INVALID = -1,
- AVARDAMAGE_ENTIRE = 0,
+ AVARDAMAGE_NONE = -1,
+ AVARDAMAGE_ENTIRE = 0,
AVARDAMAGE_BORDER,
AVARDAMAGE_SHADOW
};
@@ -243,7 +243,7 @@ class CAnimatedVariable {
std::chrono::system_clock::time_point animationBegin;
ANIMATEDVARTYPE m_eVarType = AVARTYPE_INVALID;
- AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID;
+ AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_NONE;
bool m_bRemoveEndAfterRan = true;
bool m_bRemoveBeginAfterRan = true;
diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp
index a0111c29..aff94a2d 100644
--- a/src/hyprerror/HyprError.cpp
+++ b/src/hyprerror/HyprError.cpp
@@ -1,6 +1,15 @@
#include "HyprError.hpp"
#include "../Compositor.hpp"
+CHyprError::CHyprError() {
+ m_fFadeOpacity.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_NONE);
+ m_fFadeOpacity.registerVar();
+}
+
+CHyprError::~CHyprError() {
+ m_fFadeOpacity.unregister();
+}
+
void CHyprError::queueCreate(std::string message, const CColor& color) {
m_szQueued = message;
m_cQueued = color;
@@ -12,6 +21,9 @@ void CHyprError::createQueued() {
m_tTexture.destroyTexture();
}
+ m_fFadeOpacity.setValueAndWarp(0.f);
+ m_fFadeOpacity = 1.f;
+
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
const auto SCALE = PMONITOR->scale;
@@ -40,6 +52,8 @@ void CHyprError::createQueued() {
const double WIDTH = PMONITOR->vecPixelSize.x - PAD * 2;
const double HEIGHT = (FONTSIZE + 2 * (FONTSIZE / 10.0)) * LINECOUNT + 3;
+ m_bDamageBox = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecPixelSize.x, (int)HEIGHT + (int)PAD * 2};
+
cairo_new_sub_path(CAIRO);
cairo_arc(CAIRO, X + WIDTH - RADIUS, Y + RADIUS, RADIUS, -90 * DEGREES, 0 * DEGREES);
cairo_arc(CAIRO, X + WIDTH - RADIUS, Y + HEIGHT - RADIUS, RADIUS, 0 * DEGREES, 90 * DEGREES);
@@ -107,12 +121,17 @@ void CHyprError::draw() {
}
if (m_bQueuedDestroy) {
- m_bQueuedDestroy = false;
- m_tTexture.destroyTexture();
- m_bIsCreated = false;
- m_szQueued = "";
- g_pHyprRenderer->damageMonitor(g_pCompositor->m_vMonitors.front().get());
- return;
+ if (!m_fFadeOpacity.isBeingAnimated()) {
+ if (m_fFadeOpacity.fl() == 0.f) {
+ m_bQueuedDestroy = false;
+ m_tTexture.destroyTexture();
+ m_bIsCreated = false;
+ m_szQueued = "";
+ return;
+ } else {
+ m_fFadeOpacity = 0.f;
+ }
+ }
}
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get();
@@ -120,9 +139,12 @@ void CHyprError::draw() {
if (g_pHyprOpenGL->m_RenderData.pMonitor != PMONITOR)
return; // wrong mon
- wlr_box windowBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
+ wlr_box monbox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
+
+ if (m_fFadeOpacity.isBeingAnimated())
+ g_pHyprRenderer->damageBox(&m_bDamageBox);
- g_pHyprOpenGL->renderTexture(m_tTexture, &windowBox, 1.f, 0);
+ g_pHyprOpenGL->renderTexture(m_tTexture, &monbox, m_fFadeOpacity.fl(), 0);
}
void CHyprError::destroy() {
diff --git a/src/hyprerror/HyprError.hpp b/src/hyprerror/HyprError.hpp
index 4d01e78d..26f90e40 100644
--- a/src/hyprerror/HyprError.hpp
+++ b/src/hyprerror/HyprError.hpp
@@ -2,22 +2,28 @@
#include "../defines.hpp"
#include "../render/Texture.hpp"
+#include "../helpers/AnimatedVariable.hpp"
#include <cairo/cairo.h>
class CHyprError {
public:
+ CHyprError();
+ ~CHyprError();
+
void queueCreate(std::string message, const CColor& color);
void draw();
void destroy();
private:
- void createQueued();
- std::string m_szQueued = "";
- CColor m_cQueued;
- bool m_bQueuedDestroy = false;
- bool m_bIsCreated = false;
- CTexture m_tTexture;
+ void createQueued();
+ std::string m_szQueued = "";
+ CColor m_cQueued;
+ bool m_bQueuedDestroy = false;
+ bool m_bIsCreated = false;
+ CTexture m_tTexture;
+ CAnimatedVariable m_fFadeOpacity;
+ wlr_box m_bDamageBox = {0, 0, 0, 0};
};
inline std::unique_ptr<CHyprError> g_pHyprError; // This is a full-screen error. Treat it with respect, and there can only be one at a time. \ No newline at end of file
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index cb0f6669..ad5185bd 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -223,7 +223,6 @@ void CAnimationManager::tick() {
break;
}
default: {
- Debug::log(ERR, "av has damage policy INVALID???");
break;
}
}
@@ -233,7 +232,8 @@ void CAnimationManager::tick() {
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
// manually schedule a frame
- g_pCompositor->scheduleFrameForMonitor(PMONITOR);
+ if (PMONITOR)
+ g_pCompositor->scheduleFrameForMonitor(PMONITOR);
// check if we did not finish animating. If so, trigger onAnimationEnd.
if (!av->isBeingAnimated())