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>
This commit is contained in:
MightyPlaza 2023-09-11 02:47:13 +01:00
parent bc62facc80
commit 5c2f22eb75
No known key found for this signature in database
GPG key ID: 284C27FD27A6DC0D
4 changed files with 37 additions and 16 deletions

View file

@ -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);

View file

@ -285,6 +285,10 @@ class CWindow {
std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
std::vector<IHyprWindowDecoration*> 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;

View file

@ -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();

View file

@ -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);