shadow: move workspace offset calcs to draw

fixes #3829
This commit is contained in:
Vaxry 2023-11-11 16:15:11 +00:00
parent 844da8db56
commit 52cf122a0a

View file

@ -38,13 +38,8 @@ void CHyprDropShadowDecoration::damageEntire() {
} }
void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) { void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
m_vLastWindowPos = m_pWindow->m_vRealPosition.vec();
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); m_vLastWindowSize = m_pWindow->m_vRealSize.vec();
const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
m_vLastWindowSize = pWindow->m_vRealSize.vec();
m_bLastWindowBox = {m_vLastWindowPos.x, m_vLastWindowPos.y, m_vLastWindowSize.x, m_vLastWindowSize.y}; m_bLastWindowBox = {m_vLastWindowPos.x, m_vLastWindowPos.y, m_vLastWindowSize.x, m_vLastWindowSize.y};
m_bLastWindowBoxWithDecos = g_pDecorationPositioner->getBoxWithIncludedDecos(pWindow); m_bLastWindowBoxWithDecos = g_pDecorationPositioner->getBoxWithIncludedDecos(pWindow);
@ -77,10 +72,12 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
return; // disabled return; // disabled
const auto ROUNDING = m_pWindow->rounding() + m_pWindow->getRealBorderSize(); const auto ROUNDING = m_pWindow->rounding() + m_pWindow->getRealBorderSize();
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(m_pWindow->m_iWorkspaceID);
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
// draw the shadow // draw the shadow
CBox fullBox = m_bLastWindowBoxWithDecos; CBox fullBox = m_bLastWindowBoxWithDecos;
fullBox.translate(-pMonitor->vecPosition); fullBox.translate(-pMonitor->vecPosition + WORKSPACEOFFSET);
fullBox.x -= *PSHADOWSIZE; fullBox.x -= *PSHADOWSIZE;
fullBox.y -= *PSHADOWSIZE; fullBox.y -= *PSHADOWSIZE;
fullBox.w += 2 * *PSHADOWSIZE; fullBox.w += 2 * *PSHADOWSIZE;
@ -114,8 +111,8 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
CBox withDecos = m_bLastWindowBoxWithDecos; CBox withDecos = m_bLastWindowBoxWithDecos;
// get window box // get window box
windowBox.translate(-pMonitor->vecPosition).scale(pMonitor->scale).round(); windowBox.translate(-pMonitor->vecPosition + WORKSPACEOFFSET).scale(pMonitor->scale).round();
withDecos.translate(-pMonitor->vecPosition).scale(pMonitor->scale).round(); withDecos.translate(-pMonitor->vecPosition + WORKSPACEOFFSET).scale(pMonitor->scale).round();
auto scaledDecoExtents = withDecos.extentsFrom(windowBox).round(); auto scaledDecoExtents = withDecos.extentsFrom(windowBox).round();