From 5c2f22eb756011c63dc09c5a774ffe049eff4d08 Mon Sep 17 00:00:00 2001 From: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> Date: Mon, 11 Sep 2023 02:47:13 +0100 Subject: [PATCH] store window internal and external reserved area modified: src/Window.cpp modified: src/Window.hpp modified: src/config/ConfigManager.cpp modified: src/render/Renderer.cpp modified: subprojects/wlroots Signed-off-by: MightyPlaza <123664421+MightyPlaza@users.noreply.github.com> --- src/Window.cpp | 21 +++++++++++++++++++++ src/Window.hpp | 4 ++++ src/config/ConfigManager.cpp | 6 ++---- src/render/Renderer.cpp | 22 ++++++++++------------ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index 9055101e..3c805a18 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -204,6 +204,27 @@ void CWindow::updateWindowDecos() { } } + // reset extents + m_seReservedInternal.topLeft = Vector2D(); + m_seReservedInternal.bottomRight = Vector2D(); + m_seReservedExternal.topLeft = Vector2D(); + m_seReservedExternal.bottomRight = Vector2D(); + + for (auto& wd : m_dWindowDecorations) { + const auto RESERVED = wd->getWindowDecorationReservedArea(); + if (RESERVED.isInternalDecoration) { + m_seReservedInternal.topLeft.x = std::max(m_seReservedInternal.topLeft.x, RESERVED.topLeft.x); + m_seReservedInternal.topLeft.y = std::max(m_seReservedInternal.topLeft.y, RESERVED.topLeft.y); + m_seReservedInternal.bottomRight.x = std::max(m_seReservedInternal.bottomRight.x, RESERVED.bottomRight.x); + m_seReservedInternal.bottomRight.y = std::max(m_seReservedInternal.bottomRight.y, RESERVED.bottomRight.y); + } else { + m_seReservedExternal.topLeft.x = std::max(m_seReservedExternal.topLeft.x, RESERVED.topLeft.x); + m_seReservedExternal.topLeft.y = std::max(m_seReservedExternal.topLeft.y, RESERVED.topLeft.y); + m_seReservedExternal.bottomRight.x = std::max(m_seReservedExternal.bottomRight.x, RESERVED.bottomRight.x); + m_seReservedExternal.bottomRight.y = std::max(m_seReservedExternal.bottomRight.y, RESERVED.bottomRight.y); + } + } + if (recalc) g_pLayoutManager->getCurrentLayout()->recalculateWindow(this); diff --git a/src/Window.hpp b/src/Window.hpp index dd16fdcb..bfe4231e 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -285,6 +285,10 @@ class CWindow { std::deque> m_dWindowDecorations; std::vector m_vDecosToRemove; + // Window decorations internal and external reserved area + SWindowDecorationExtents m_seReservedInternal; + SWindowDecorationExtents m_seReservedExternal; + // Special render data, rules, etc SWindowSpecialRenderData m_sSpecialRenderData; SWindowAdditionalConfigData m_sAdditionalConfigData; diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 45ebcbc5..8302dfec 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -1650,14 +1650,12 @@ void CConfigManager::loadConfigLoadVars() { w->updateDynamicRules(); w->updateSpecialRenderData(); + for (auto& wd : w->m_dWindowDecorations) wd->forceReload(w.get()); + g_pLayoutManager->getCurrentLayout()->recalculateWindow(w.get()); } - // TODO: hack needed for decorations, fix later - for (auto& m : g_pCompositor->m_vMonitors) - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); - // Update window border colors g_pCompositor->updateAllWindowsAnimatedDecorationValues(); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 6771dbb5..8b8de52c 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -384,20 +384,11 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* renderdata.y += offset.y; } - SWindowDecorationExtents borderExtents; // render window decorations first, if not fullscreen full if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) { if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) - for (auto& wd : pWindow->m_dWindowDecorations) { + for (auto& wd : pWindow->m_dWindowDecorations) wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha, offset); - const auto EXTENTS = wd->getWindowDecorationExtents(); - if (EXTENTS.isInternalDecoration) { - borderExtents.topLeft.x += EXTENTS.topLeft.x; - borderExtents.topLeft.y += EXTENTS.topLeft.y; - borderExtents.bottomRight.x += EXTENTS.bottomRight.x; - borderExtents.bottomRight.y += EXTENTS.bottomRight.y; - } - } static auto* const PXWLUSENN = &g_pConfigManager->getConfigValuePtr("xwayland:use_nearest_neighbor")->intValue; if (pWindow->m_bIsX11 && *PXWLUSENN) @@ -418,8 +409,15 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec* } wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h}; - wlr_box borderBox = {renderdata.x - pMonitor->vecPosition.x - borderExtents.topLeft.x, renderdata.y - pMonitor->vecPosition.y - borderExtents.topLeft.y, - renderdata.w + borderExtents.topLeft.x + borderExtents.bottomRight.x, renderdata.h + borderExtents.topLeft.y + borderExtents.bottomRight.y}; + wlr_box borderBox; + + if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) + borderBox = {renderdata.x - pMonitor->vecPosition.x - pWindow->m_seReservedInternal.topLeft.x, + renderdata.y - pMonitor->vecPosition.y - pWindow->m_seReservedInternal.topLeft.y, + renderdata.w + pWindow->m_seReservedInternal.topLeft.x + pWindow->m_seReservedInternal.bottomRight.x, + renderdata.h + pWindow->m_seReservedInternal.topLeft.y + pWindow->m_seReservedInternal.bottomRight.y}; + else + borderBox = windowBox; scaleBox(&windowBox, pMonitor->scale); scaleBox(&borderBox, pMonitor->scale);