From 158260c0ec5ab28937281f493f81a3f4590673f0 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 10 Dec 2021 23:28:00 +0100 Subject: [PATCH] border animation optimization --- example/hypr.conf | 1 + src/defines.hpp | 4 +++- src/utilities/AnimationUtil.cpp | 10 ++++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/example/hypr.conf b/example/hypr.conf index 91bb275..15c69c6 100644 --- a/example/hypr.conf +++ b/example/hypr.conf @@ -50,6 +50,7 @@ Animations { enabled=1 speed=5 cheap=1 # highly recommended + borders=0 } # keybinds diff --git a/src/defines.hpp b/src/defines.hpp index ceea6e6..648f6e0 100644 --- a/src/defines.hpp +++ b/src/defines.hpp @@ -82,4 +82,6 @@ #define CONTAINS(s, f) s.find(f) != std::string::npos #define RETURNIFBAR if (g_pWindowManager->statusBar) return; -#define RETURNIFMAIN if (!g_pWindowManager->statusBar) return; \ No newline at end of file +#define RETURNIFMAIN if (!g_pWindowManager->statusBar) return; + +#define COLORDELTAOVERX(c, c1, d) (abs(RED(c) - RED(c1)) > d / 255.f || abs(GREEN(c) - GREEN(c1)) > d / 255.f || abs(BLUE(c) - BLUE(c1)) > d / 255.f || abs(ALPHA(c) - ALPHA(c1)) > d / 255.f) \ No newline at end of file diff --git a/src/utilities/AnimationUtil.cpp b/src/utilities/AnimationUtil.cpp index eb13787..5f05b5a 100644 --- a/src/utilities/AnimationUtil.cpp +++ b/src/utilities/AnimationUtil.cpp @@ -19,17 +19,19 @@ void AnimationUtil::move() { // Border animations if (window.getDrawable() > 0) { if (window.getEffectiveBorderColor().getAsUint32() != window.getRealBorderColor().getAsUint32() /* As uint32 to round and not spam */) { - // interp border color if enabled + const auto PREVCOLOR = window.getRealBorderColor().getAsUint32(); + if (ConfigManager::getInt("anim:borders") == 1) { window.setRealBorderColor(parabolicColor(window.getRealBorderColor(), window.getEffectiveBorderColor(), ANIMATIONSPEED)); } else { window.setRealBorderColor(window.getEffectiveBorderColor()); } - updateRequired = true; - window.setDirty(true); - + if (COLORDELTAOVERX(PREVCOLOR, window.getRealBorderColor().getAsUint32(), 2)) { + updateRequired = true; + window.setDirty(true); + } } }