From c7fbea3368452c34c47a4a634e642de6cd4090cb Mon Sep 17 00:00:00 2001 From: thejch <66577496+thejch@users.noreply.github.com> Date: Sat, 23 Mar 2024 15:14:50 -0700 Subject: [PATCH] animations: Fix animation issue in focusworkspaceoncurrentmonitor (#5202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * dont render when workspace offset * add guard * can remove useless code now if workspace offset is not taken into account * clang-format * when special workspace is moved, set anim to move * add offset back * make it a configurable option because some folks apparently can't align their monitors correctly and may not want this feature😔 * remove config option --- src/helpers/Monitor.cpp | 1 + src/managers/AnimationManager.cpp | 12 ++++++------ src/render/Renderer.cpp | 6 ++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 9126f936b..3edb7ca4e 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -667,6 +667,7 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) { if (w->m_iWorkspaceID == pWorkspace->m_iID) { w->m_iMonitorID = ID; w->updateSurfaceScaleTransformDetails(); + w->setAnimationsToMove(); const auto MIDDLE = w->middle(); if (w->m_bIsFloating && !VECINRECT(MIDDLE, vecPosition.x, vecPosition.y, vecPosition.x + vecSize.x, vecPosition.y + vecSize.y) && w->m_iX11Type != 2) { diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index 7d2a86e7e..a14bc195c 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -109,14 +109,13 @@ void CAnimationManager::tick() { g_pHyprRenderer->damageWindow(w.get()); } - // if a workspace window is on any monitor, damage it + // if a special workspace window is on any monitor, damage it for (auto& w : g_pCompositor->m_vWindows) { for (auto& m : g_pCompositor->m_vMonitors) { - if (w->m_iWorkspaceID == PWORKSPACE->m_iID && g_pCompositor->windowValidMapped(w.get()) && g_pHyprRenderer->shouldRenderWindow(w.get(), m.get(), PWORKSPACE)) { + if (w->m_iWorkspaceID == PWORKSPACE->m_iID && PWORKSPACE->m_bIsSpecialWorkspace && g_pCompositor->windowValidMapped(w.get()) && + g_pHyprRenderer->shouldRenderWindow(w.get(), m.get(), PWORKSPACE)) { CBox bb = w->getFullWindowBoundingBox(); bb.translate(PWORKSPACE->m_vRenderOffset.value()); - if (PWORKSPACE->m_bIsSpecialWorkspace) - bb.scaleFromCenter(1.1); // for some reason special ws windows getting border artifacts if you close it too quickly... bb.intersection({m->vecPosition, m->vecSize}); g_pHyprRenderer->damageBox(&bb); } @@ -197,7 +196,8 @@ void CAnimationManager::tick() { PWINDOW->updateWindowDecos(); auto bb = PWINDOW->getFullWindowBoundingBox(); const auto PWINDOWWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); - bb.translate(PWINDOWWORKSPACE->m_vRenderOffset.value()); + if (PWINDOWWORKSPACE) + bb.translate(PWINDOWWORKSPACE->m_vRenderOffset.value()); g_pHyprRenderer->damageBox(&bb); } else if (PWORKSPACE) { for (auto& w : g_pCompositor->m_vWindows) { @@ -245,7 +245,7 @@ void CAnimationManager::tick() { BORDERSIZE + ROUNDINGSIZE); // bottom // damage for new box - CBox WLRBOXNEW = {PWINDOW->m_vRealPosition.value(), PWINDOW->m_vRealSize.value()}; + CBox WLRBOXNEW = PWINDOW->getFullWindowBoundingBox(); const auto PWINDOWWORKSPACE = g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID); if (PWINDOWWORKSPACE) WLRBOXNEW.translate(PWINDOWWORKSPACE->m_vRenderOffset.value()); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 88035112d..7f83c429e 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -217,7 +217,7 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor, CWo } } - if (pWindow->m_iWorkspaceID == pWorkspace->m_iID) + if (pWindow->m_iWorkspaceID == pWorkspace->m_iID && pWorkspace->m_iMonitorID == pMonitor->ID) return true; // if not, check if it maybe is active on a different monitor. @@ -228,9 +228,11 @@ bool CHyprRenderer::shouldRenderWindow(CWindow* pWindow, CMonitor* pMonitor, CWo return true; if (pWindow->m_vRealPosition.isBeingAnimated()) { + if (PWINDOWWORKSPACE && !PWINDOWWORKSPACE->m_bIsSpecialWorkspace && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated()) + return false; // render window if window and monitor intersect // (when moving out of or through a monitor) - CBox windowBox = {pWindow->m_vRealPosition.value(), pWindow->m_vRealSize.value()}; + CBox windowBox = pWindow->getFullWindowBoundingBox(); const CBox monitorBox = {pMonitor->vecPosition, pMonitor->vecSize}; if (!windowBox.intersection(monitorBox).empty()) return true;