summaryrefslogtreecommitdiff
path: root/src/render/decorations
diff options
context:
space:
mode:
authorthejch <66577496+thejch@users.noreply.github.com>2024-03-30 18:14:26 -0700
committerGitHub <noreply@github.com>2024-03-31 02:14:26 +0100
commit16a9c16d9f99bd8be9f1bb15442b001fdf2ea759 (patch)
treef9cb60dc2d92519079699e9cb6e71e562b55a8a5 /src/render/decorations
parent1cc9a44318e53a34f41cc36483502de985b88cf8 (diff)
renderer/animations: Fix various inaccurate damage tracking issues and offsets (#5297)
Diffstat (limited to 'src/render/decorations')
-rw-r--r--src/render/decorations/CHyprBorderDecoration.cpp34
-rw-r--r--src/render/decorations/CHyprBorderDecoration.hpp2
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.cpp42
-rw-r--r--src/render/decorations/CHyprDropShadowDecoration.hpp2
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.cpp18
-rw-r--r--src/render/decorations/CHyprGroupBarDecoration.hpp2
-rw-r--r--src/render/decorations/IHyprWindowDecoration.hpp2
7 files changed, 82 insertions, 20 deletions
diff --git a/src/render/decorations/CHyprBorderDecoration.cpp b/src/render/decorations/CHyprBorderDecoration.cpp
index ea40ee65..4981d2ea 100644
--- a/src/render/decorations/CHyprBorderDecoration.cpp
+++ b/src/render/decorations/CHyprBorderDecoration.cpp
@@ -45,14 +45,14 @@ CBox CHyprBorderDecoration::assignedBoxGlobal() {
return box.translate(WORKSPACEOFFSET);
}
-void CHyprBorderDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
+void CHyprBorderDecoration::draw(CMonitor* pMonitor, float a) {
if (doesntWantBorders())
return;
if (m_bAssignedGeometry.width < m_seExtents.topLeft.x + 1 || m_bAssignedGeometry.height < m_seExtents.topLeft.y + 1)
return;
- CBox windowBox = assignedBoxGlobal().translate(-pMonitor->vecPosition + offset).expand(-m_pWindow->getRealBorderSize()).scale(pMonitor->scale).round();
+ CBox windowBox = assignedBoxGlobal().translate(-pMonitor->vecPosition + m_pWindow->m_vFloatingOffset).expand(-m_pWindow->getRealBorderSize()).scale(pMonitor->scale).round();
if (windowBox.width < 1 || windowBox.height < 1)
return;
@@ -87,7 +87,35 @@ void CHyprBorderDecoration::updateWindow(CWindow*) {
}
void CHyprBorderDecoration::damageEntire() {
- ; // ignored, done in animationManager. todo, move.
+ if (!g_pCompositor->windowValidMapped(m_pWindow))
+ return;
+
+ auto surfaceBox = m_pWindow->getWindowMainSurfaceBox();
+ const auto ROUNDING = m_pWindow->rounding();
+ const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 1;
+ const auto BORDERSIZE = m_pWindow->getRealBorderSize();
+
+ const auto PWINDOWWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID);
+ if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
+ surfaceBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value());
+ surfaceBox.translate(m_pWindow->m_vFloatingOffset);
+
+ CBox surfaceBoxExpandedBorder = surfaceBox;
+ surfaceBoxExpandedBorder.expand(BORDERSIZE);
+ CBox surfaceBoxShrunkRounding = surfaceBox;
+ surfaceBoxShrunkRounding.expand(-ROUNDINGSIZE);
+
+ CRegion borderRegion(surfaceBoxExpandedBorder);
+ borderRegion.subtract(surfaceBoxShrunkRounding);
+
+ for (auto& m : g_pCompositor->m_vMonitors) {
+ if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow, m.get())) {
+ const CRegion monitorRegion({m->vecPosition, m->vecSize});
+ borderRegion.subtract(monitorRegion);
+ }
+ }
+
+ g_pHyprRenderer->damageRegion(borderRegion);
}
eDecorationLayer CHyprBorderDecoration::getDecorationLayer() {
diff --git a/src/render/decorations/CHyprBorderDecoration.hpp b/src/render/decorations/CHyprBorderDecoration.hpp
index 9c0bcc33..9b9df7ab 100644
--- a/src/render/decorations/CHyprBorderDecoration.hpp
+++ b/src/render/decorations/CHyprBorderDecoration.hpp
@@ -11,7 +11,7 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply);
- virtual void draw(CMonitor*, float a, const Vector2D& offset);
+ virtual void draw(CMonitor*, float a);
virtual eDecorationType getDecorationType();
diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp
index 588b23a4..99d08828 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.cpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.cpp
@@ -41,9 +41,37 @@ void CHyprDropShadowDecoration::damageEntire() {
if (*PSHADOWS != 1)
return; // disabled
- CBox dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
- m_vLastWindowSize.y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y};
- g_pHyprRenderer->damageBox(&dm);
+ CBox shadowBox = {m_pWindow->m_vRealPosition.value().x - m_seExtents.topLeft.x, m_pWindow->m_vRealPosition.value().y - m_seExtents.topLeft.y,
+ m_pWindow->m_vRealSize.value().x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
+ m_pWindow->m_vRealSize.value().y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y};
+
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID);
+ if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
+ shadowBox.translate(PWORKSPACE->m_vRenderOffset.value());
+ shadowBox.translate(m_pWindow->m_vFloatingOffset);
+
+ static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow_ignore_window");
+ const auto ROUNDING = m_pWindow->rounding();
+ const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 1;
+
+ CRegion shadowRegion(shadowBox);
+ if (*PSHADOWIGNOREWINDOW) {
+ CBox surfaceBox = m_pWindow->getWindowMainSurfaceBox();
+ if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
+ surfaceBox.translate(PWORKSPACE->m_vRenderOffset.value());
+ surfaceBox.translate(m_pWindow->m_vFloatingOffset);
+ surfaceBox.expand(-ROUNDINGSIZE);
+ shadowRegion.subtract(CRegion(surfaceBox));
+ }
+
+ for (auto& m : g_pCompositor->m_vMonitors) {
+ if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow, m.get())) {
+ const CRegion monitorRegion({m->vecPosition, m->vecSize});
+ shadowRegion.subtract(monitorRegion);
+ }
+ }
+
+ g_pHyprRenderer->damageRegion(shadowRegion);
}
void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
@@ -54,7 +82,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
m_bLastWindowBoxWithDecos = g_pDecorationPositioner->getBoxWithIncludedDecos(pWindow);
}
-void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
+void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
if (!g_pCompositor->windowValidMapped(m_pWindow))
return;
@@ -98,12 +126,13 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
// scale the box in relation to the center of the box
fullBox.scaleFromCenter(SHADOWSCALE).translate(*PSHADOWOFFSET);
+ updateWindow(m_pWindow);
m_vLastWindowPos += WORKSPACEOFFSET;
m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2},
{fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2,
fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}};
- fullBox.translate(offset);
+ fullBox.translate(m_pWindow->m_vFloatingOffset);
if (fullBox.width < 1 || fullBox.height < 1)
return; // don't draw invisible shadows
@@ -125,6 +154,9 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
windowBox.translate(-pMonitor->vecPosition + WORKSPACEOFFSET);
withDecos.translate(-pMonitor->vecPosition + WORKSPACEOFFSET);
+ windowBox.translate(m_pWindow->m_vFloatingOffset);
+ withDecos.translate(m_pWindow->m_vFloatingOffset);
+
auto scaledExtentss = withDecos.extentsFrom(windowBox);
scaledExtentss = scaledExtentss * pMonitor->scale;
scaledExtentss = scaledExtentss.round();
diff --git a/src/render/decorations/CHyprDropShadowDecoration.hpp b/src/render/decorations/CHyprDropShadowDecoration.hpp
index 3b389550..fcc5f873 100644
--- a/src/render/decorations/CHyprDropShadowDecoration.hpp
+++ b/src/render/decorations/CHyprDropShadowDecoration.hpp
@@ -11,7 +11,7 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply);
- virtual void draw(CMonitor*, float a, const Vector2D& offset);
+ virtual void draw(CMonitor*, float a);
virtual eDecorationType getDecorationType();
diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp
index a03d97f9..ce683ac1 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.cpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.cpp
@@ -83,10 +83,11 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
void CHyprGroupBarDecoration::damageEntire() {
auto box = assignedBoxGlobal();
+ box.translate(m_pWindow->m_vFloatingOffset);
g_pHyprRenderer->damageBox(&box);
}
-void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
+void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
// get how many bars we will draw
int barsToDraw = m_dwGroupMembers.size();
@@ -110,8 +111,9 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
int xoff = 0;
for (int i = 0; i < barsToDraw; ++i) {
- CBox rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + offset.x,
- ASSIGNEDBOX.y + ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT - pMonitor->vecPosition.y + offset.y, m_fBarWidth, BAR_INDICATOR_HEIGHT};
+ CBox rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
+ ASSIGNEDBOX.y + ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y, m_fBarWidth,
+ BAR_INDICATOR_HEIGHT};
if (rect.width <= 0 || rect.height <= 0)
break;
@@ -135,7 +137,8 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
color.a *= a;
g_pHyprOpenGL->renderRect(&rect, color);
- rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + offset.x, ASSIGNEDBOX.y - pMonitor->vecPosition.y + offset.y + BAR_PADDING_OUTER_VERT, m_fBarWidth,
+ rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
+ ASSIGNEDBOX.y - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y + BAR_PADDING_OUTER_VERT, m_fBarWidth,
ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT * 2};
rect.scale(pMonitor->scale);
@@ -505,9 +508,8 @@ CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID);
- if (!PWORKSPACE)
- return box;
+ if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
+ box.translate(PWORKSPACE->m_vRenderOffset.value());
- const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
- return box.translate(WORKSPACEOFFSET);
+ return box;
}
diff --git a/src/render/decorations/CHyprGroupBarDecoration.hpp b/src/render/decorations/CHyprGroupBarDecoration.hpp
index 04f5123b..24635f6e 100644
--- a/src/render/decorations/CHyprGroupBarDecoration.hpp
+++ b/src/render/decorations/CHyprGroupBarDecoration.hpp
@@ -27,7 +27,7 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply);
- virtual void draw(CMonitor*, float a, const Vector2D& offset);
+ virtual void draw(CMonitor*, float a);
virtual eDecorationType getDecorationType();
diff --git a/src/render/decorations/IHyprWindowDecoration.hpp b/src/render/decorations/IHyprWindowDecoration.hpp
index d3d1a5dd..10426439 100644
--- a/src/render/decorations/IHyprWindowDecoration.hpp
+++ b/src/render/decorations/IHyprWindowDecoration.hpp
@@ -39,7 +39,7 @@ class IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply) = 0;
- virtual void draw(CMonitor*, float a, const Vector2D& offset = Vector2D()) = 0;
+ virtual void draw(CMonitor*, float a) = 0;
virtual eDecorationType getDecorationType() = 0;