internal: Window storage rework - part 1 (#5762)

* Window storage rework - part 1

* format

* remove useless include

* fix pch

* format

* fix crash in dwindle

* fix vram leak

* prefer .expired() for bool checks
This commit is contained in:
Vaxry 2024-04-27 12:43:12 +01:00 committed by GitHub
parent 25aec3ac8c
commit bca7804bb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 1416 additions and 1346 deletions

View file

@ -2,7 +2,7 @@
#include "../../Compositor.hpp"
#include "../../config/ConfigValue.hpp"
CHyprBorderDecoration::CHyprBorderDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
CHyprBorderDecoration::CHyprBorderDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow) {
m_pWindow = pWindow;
}
@ -11,7 +11,7 @@ CHyprBorderDecoration::~CHyprBorderDecoration() {
}
SDecorationPositioningInfo CHyprBorderDecoration::getPositioningInfo() {
const auto BORDERSIZE = m_pWindow->getRealBorderSize();
const auto BORDERSIZE = m_pWindow.lock()->getRealBorderSize();
m_seExtents = {{BORDERSIZE, BORDERSIZE}, {BORDERSIZE, BORDERSIZE}};
if (doesntWantBorders())
@ -34,14 +34,14 @@ void CHyprBorderDecoration::onPositioningReply(const SDecorationPositioningReply
CBox CHyprBorderDecoration::assignedBoxGlobal() {
CBox box = m_bAssignedGeometry;
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_pWindow));
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_BOTTOM | DECORATION_EDGE_LEFT | DECORATION_EDGE_RIGHT | DECORATION_EDGE_TOP, m_pWindow.lock()));
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
const auto PWORKSPACE = m_pWindow.lock()->m_pWorkspace;
if (!PWORKSPACE)
return box;
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow.lock()->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
return box.translate(WORKSPACEOFFSET);
}
@ -52,28 +52,29 @@ void CHyprBorderDecoration::draw(CMonitor* pMonitor, float a) {
if (m_bAssignedGeometry.width < m_seExtents.topLeft.x + 1 || m_bAssignedGeometry.height < m_seExtents.topLeft.y + 1)
return;
CBox windowBox = assignedBoxGlobal().translate(-pMonitor->vecPosition + m_pWindow->m_vFloatingOffset).expand(-m_pWindow->getRealBorderSize()).scale(pMonitor->scale).round();
CBox windowBox =
assignedBoxGlobal().translate(-pMonitor->vecPosition + m_pWindow.lock()->m_vFloatingOffset).expand(-m_pWindow.lock()->getRealBorderSize()).scale(pMonitor->scale).round();
if (windowBox.width < 1 || windowBox.height < 1)
return;
auto grad = m_pWindow->m_cRealBorderColor;
const bool ANIMATED = m_pWindow->m_fBorderFadeAnimationProgress.isBeingAnimated();
float a1 = a * (ANIMATED ? m_pWindow->m_fBorderFadeAnimationProgress.value() : 1.f);
auto grad = m_pWindow.lock()->m_cRealBorderColor;
const bool ANIMATED = m_pWindow.lock()->m_fBorderFadeAnimationProgress.isBeingAnimated();
float a1 = a * (ANIMATED ? m_pWindow.lock()->m_fBorderFadeAnimationProgress.value() : 1.f);
if (m_pWindow->m_fBorderAngleAnimationProgress.getConfig()->pValues->internalEnabled) {
grad.m_fAngle += m_pWindow->m_fBorderAngleAnimationProgress.value() * M_PI * 2;
if (m_pWindow.lock()->m_fBorderAngleAnimationProgress.getConfig()->pValues->internalEnabled) {
grad.m_fAngle += m_pWindow.lock()->m_fBorderAngleAnimationProgress.value() * M_PI * 2;
grad.m_fAngle = normalizeAngleRad(grad.m_fAngle);
}
int borderSize = m_pWindow->getRealBorderSize();
const auto ROUNDING = m_pWindow->rounding() * pMonitor->scale;
int borderSize = m_pWindow.lock()->getRealBorderSize();
const auto ROUNDING = m_pWindow.lock()->rounding() * pMonitor->scale;
g_pHyprOpenGL->renderBorder(&windowBox, grad, ROUNDING, borderSize, a1);
if (ANIMATED) {
float a2 = a * (1.f - m_pWindow->m_fBorderFadeAnimationProgress.value());
g_pHyprOpenGL->renderBorder(&windowBox, m_pWindow->m_cRealBorderColorPrevious, ROUNDING, borderSize, a2);
float a2 = a * (1.f - m_pWindow.lock()->m_fBorderFadeAnimationProgress.value());
g_pHyprOpenGL->renderBorder(&windowBox, m_pWindow.lock()->m_cRealBorderColorPrevious, ROUNDING, borderSize, a2);
}
}
@ -81,24 +82,24 @@ eDecorationType CHyprBorderDecoration::getDecorationType() {
return DECORATION_BORDER;
}
void CHyprBorderDecoration::updateWindow(CWindow*) {
if (m_pWindow->getRealBorderSize() != m_seExtents.topLeft.x)
void CHyprBorderDecoration::updateWindow(PHLWINDOW) {
if (m_pWindow.lock()->getRealBorderSize() != m_seExtents.topLeft.x)
g_pDecorationPositioner->repositionDeco(this);
}
void CHyprBorderDecoration::damageEntire() {
if (!g_pCompositor->windowValidMapped(m_pWindow))
if (!validMapped(m_pWindow))
return;
auto surfaceBox = m_pWindow->getWindowMainSurfaceBox();
const auto ROUNDING = m_pWindow->rounding();
auto surfaceBox = m_pWindow.lock()->getWindowMainSurfaceBox();
const auto ROUNDING = m_pWindow.lock()->rounding();
const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 2;
const auto BORDERSIZE = m_pWindow->getRealBorderSize() + 1;
const auto BORDERSIZE = m_pWindow.lock()->getRealBorderSize() + 1;
const auto PWINDOWWORKSPACE = m_pWindow->m_pWorkspace;
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
const auto PWINDOWWORKSPACE = m_pWindow.lock()->m_pWorkspace;
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow.lock()->m_bPinned)
surfaceBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value());
surfaceBox.translate(m_pWindow->m_vFloatingOffset);
surfaceBox.translate(m_pWindow.lock()->m_vFloatingOffset);
CBox surfaceBoxExpandedBorder = surfaceBox;
surfaceBoxExpandedBorder.expand(BORDERSIZE);
@ -109,7 +110,7 @@ void CHyprBorderDecoration::damageEntire() {
borderRegion.subtract(surfaceBoxShrunkRounding);
for (auto& m : g_pCompositor->m_vMonitors) {
if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow, m.get())) {
if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow.lock(), m.get())) {
const CRegion monitorRegion({m->vecPosition, m->vecSize});
borderRegion.subtract(monitorRegion);
}
@ -133,5 +134,5 @@ std::string CHyprBorderDecoration::getDisplayName() {
}
bool CHyprBorderDecoration::doesntWantBorders() {
return !m_pWindow->m_sSpecialRenderData.border || m_pWindow->m_bX11DoesntWantBorders || m_pWindow->getRealBorderSize() == 0;
return !m_pWindow.lock()->m_sSpecialRenderData.border || m_pWindow.lock()->m_bX11DoesntWantBorders || m_pWindow.lock()->getRealBorderSize() == 0;
}