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:
parent
25aec3ac8c
commit
bca7804bb6
72 changed files with 1416 additions and 1346 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class CHyprBorderDecoration : public IHyprWindowDecoration {
|
||||
public:
|
||||
CHyprBorderDecoration(CWindow*);
|
||||
CHyprBorderDecoration(PHLWINDOW);
|
||||
virtual ~CHyprBorderDecoration();
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo();
|
||||
|
|
@ -15,7 +15,7 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
|
|||
|
||||
virtual eDecorationType getDecorationType();
|
||||
|
||||
virtual void updateWindow(CWindow*);
|
||||
virtual void updateWindow(PHLWINDOW);
|
||||
|
||||
virtual void damageEntire();
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
|
|||
SWindowDecorationExtents m_seExtents;
|
||||
SWindowDecorationExtents m_seReportedExtents;
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
PHLWINDOWREF m_pWindow;
|
||||
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
#include "../../Compositor.hpp"
|
||||
#include "../../config/ConfigValue.hpp"
|
||||
|
||||
CHyprDropShadowDecoration::CHyprDropShadowDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
|
||||
CHyprDropShadowDecoration::CHyprDropShadowDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow) {
|
||||
m_pWindow = pWindow;
|
||||
}
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ SDecorationPositioningInfo CHyprDropShadowDecoration::getPositioningInfo() {
|
|||
}
|
||||
|
||||
void CHyprDropShadowDecoration::onPositioningReply(const SDecorationPositioningReply& reply) {
|
||||
updateWindow(m_pWindow);
|
||||
updateWindow(m_pWindow.lock());
|
||||
}
|
||||
|
||||
uint64_t CHyprDropShadowDecoration::getDecorationFlags() {
|
||||
|
|
@ -41,31 +41,33 @@ void CHyprDropShadowDecoration::damageEntire() {
|
|||
if (*PSHADOWS != 1)
|
||||
return; // disabled
|
||||
|
||||
CBox shadowBox = {m_pWindow->m_vRealPosition.value().x - m_seExtents.topLeft.x, m_pWindow->m_vRealPosition.value().y - m_seExtents.topLeft.y,
|
||||
m_pWindow->m_vRealSize.value().x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
|
||||
m_pWindow->m_vRealSize.value().y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y};
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
|
||||
CBox shadowBox = {PWINDOW->m_vRealPosition.value().x - m_seExtents.topLeft.x, PWINDOW->m_vRealPosition.value().y - m_seExtents.topLeft.y,
|
||||
PWINDOW->m_vRealSize.value().x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
|
||||
PWINDOW->m_vRealSize.value().y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y};
|
||||
|
||||
const auto PWORKSPACE = PWINDOW->m_pWorkspace;
|
||||
if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !PWINDOW->m_bPinned)
|
||||
shadowBox.translate(PWORKSPACE->m_vRenderOffset.value());
|
||||
shadowBox.translate(m_pWindow->m_vFloatingOffset);
|
||||
shadowBox.translate(PWINDOW->m_vFloatingOffset);
|
||||
|
||||
static auto PSHADOWIGNOREWINDOW = CConfigValue<Hyprlang::INT>("decoration:shadow_ignore_window");
|
||||
const auto ROUNDING = m_pWindow->rounding();
|
||||
const auto ROUNDING = PWINDOW->rounding();
|
||||
const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 1;
|
||||
|
||||
CRegion shadowRegion(shadowBox);
|
||||
if (*PSHADOWIGNOREWINDOW) {
|
||||
CBox surfaceBox = m_pWindow->getWindowMainSurfaceBox();
|
||||
if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
|
||||
CBox surfaceBox = PWINDOW->getWindowMainSurfaceBox();
|
||||
if (PWORKSPACE && PWORKSPACE->m_vRenderOffset.isBeingAnimated() && !PWINDOW->m_bPinned)
|
||||
surfaceBox.translate(PWORKSPACE->m_vRenderOffset.value());
|
||||
surfaceBox.translate(m_pWindow->m_vFloatingOffset);
|
||||
surfaceBox.translate(PWINDOW->m_vFloatingOffset);
|
||||
surfaceBox.expand(-ROUNDINGSIZE);
|
||||
shadowRegion.subtract(CRegion(surfaceBox));
|
||||
}
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||
if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow, m.get())) {
|
||||
if (!g_pHyprRenderer->shouldRenderWindow(PWINDOW, m.get())) {
|
||||
const CRegion monitorRegion({m->vecPosition, m->vecSize});
|
||||
shadowRegion.subtract(monitorRegion);
|
||||
}
|
||||
|
|
@ -74,9 +76,11 @@ void CHyprDropShadowDecoration::damageEntire() {
|
|||
g_pHyprRenderer->damageRegion(shadowRegion);
|
||||
}
|
||||
|
||||
void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
|
||||
m_vLastWindowPos = m_pWindow->m_vRealPosition.value();
|
||||
m_vLastWindowSize = m_pWindow->m_vRealSize.value();
|
||||
void CHyprDropShadowDecoration::updateWindow(PHLWINDOW pWindow) {
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
m_vLastWindowPos = PWINDOW->m_vRealPosition.value();
|
||||
m_vLastWindowSize = PWINDOW->m_vRealSize.value();
|
||||
|
||||
m_bLastWindowBox = {m_vLastWindowPos.x, m_vLastWindowPos.y, m_vLastWindowSize.x, m_vLastWindowSize.y};
|
||||
m_bLastWindowBoxWithDecos = g_pDecorationPositioner->getBoxWithIncludedDecos(pWindow);
|
||||
|
|
@ -84,19 +88,21 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
|
|||
|
||||
void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(m_pWindow))
|
||||
const auto PWINDOW = m_pWindow.lock();
|
||||
|
||||
if (!validMapped(PWINDOW))
|
||||
return;
|
||||
|
||||
if (m_pWindow->m_cRealShadowColor.value() == CColor(0, 0, 0, 0))
|
||||
if (PWINDOW->m_cRealShadowColor.value() == CColor(0, 0, 0, 0))
|
||||
return; // don't draw invisible shadows
|
||||
|
||||
if (!m_pWindow->m_sSpecialRenderData.decorate)
|
||||
if (!PWINDOW->m_sSpecialRenderData.decorate)
|
||||
return;
|
||||
|
||||
if (!m_pWindow->m_sSpecialRenderData.shadow)
|
||||
if (!PWINDOW->m_sSpecialRenderData.shadow)
|
||||
return;
|
||||
|
||||
if (m_pWindow->m_sAdditionalConfigData.forceNoShadow)
|
||||
if (PWINDOW->m_sAdditionalConfigData.forceNoShadow)
|
||||
return;
|
||||
|
||||
static auto PSHADOWS = CConfigValue<Hyprlang::INT>("decoration:drop_shadow");
|
||||
|
|
@ -108,10 +114,10 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
if (*PSHADOWS != 1)
|
||||
return; // disabled
|
||||
|
||||
const auto ROUNDINGBASE = m_pWindow->rounding();
|
||||
const auto ROUNDING = ROUNDINGBASE > 0 ? ROUNDINGBASE + m_pWindow->getRealBorderSize() : 0;
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
const auto ROUNDINGBASE = PWINDOW->rounding();
|
||||
const auto ROUNDING = ROUNDINGBASE > 0 ? ROUNDINGBASE + PWINDOW->getRealBorderSize() : 0;
|
||||
const auto PWORKSPACE = PWINDOW->m_pWorkspace;
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !PWINDOW->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
|
||||
// draw the shadow
|
||||
CBox fullBox = m_bLastWindowBoxWithDecos;
|
||||
|
|
@ -126,13 +132,13 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
// scale the box in relation to the center of the box
|
||||
fullBox.scaleFromCenter(SHADOWSCALE).translate(*PSHADOWOFFSET);
|
||||
|
||||
updateWindow(m_pWindow);
|
||||
updateWindow(PWINDOW);
|
||||
m_vLastWindowPos += WORKSPACEOFFSET;
|
||||
m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2},
|
||||
{fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2,
|
||||
fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}};
|
||||
|
||||
fullBox.translate(m_pWindow->m_vFloatingOffset);
|
||||
fullBox.translate(PWINDOW->m_vFloatingOffset);
|
||||
|
||||
if (fullBox.width < 1 || fullBox.height < 1)
|
||||
return; // don't draw invisible shadows
|
||||
|
|
@ -154,8 +160,8 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
windowBox.translate(-pMonitor->vecPosition + WORKSPACEOFFSET);
|
||||
withDecos.translate(-pMonitor->vecPosition + WORKSPACEOFFSET);
|
||||
|
||||
windowBox.translate(m_pWindow->m_vFloatingOffset);
|
||||
withDecos.translate(m_pWindow->m_vFloatingOffset);
|
||||
windowBox.translate(PWINDOW->m_vFloatingOffset);
|
||||
withDecos.translate(PWINDOW->m_vFloatingOffset);
|
||||
|
||||
auto scaledExtentss = withDecos.extentsFrom(windowBox);
|
||||
scaledExtentss = scaledExtentss * pMonitor->scale;
|
||||
|
|
@ -181,7 +187,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
g_pHyprOpenGL->renderRect(&fullBox, CColor(0, 0, 0, 1), 0);
|
||||
|
||||
// render white shadow with the alpha of the shadow color (otherwise we clear with alpha later and shit it to 2 bit)
|
||||
g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, CColor(1, 1, 1, m_pWindow->m_cRealShadowColor.value().a), a);
|
||||
g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, CColor(1, 1, 1, PWINDOW->m_cRealShadowColor.value().a), a);
|
||||
|
||||
// render black window box ("clip")
|
||||
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 1.0), ROUNDING * pMonitor->scale);
|
||||
|
|
@ -189,7 +195,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
alphaSwapFB.bind();
|
||||
|
||||
// alpha swap just has the shadow color. It will be the "texture" to render.
|
||||
g_pHyprOpenGL->renderRect(&fullBox, m_pWindow->m_cRealShadowColor.value().stripA(), 0);
|
||||
g_pHyprOpenGL->renderRect(&fullBox, PWINDOW->m_cRealShadowColor.value().stripA(), 0);
|
||||
|
||||
LASTFB->bind();
|
||||
|
||||
|
|
@ -202,7 +208,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
|
||||
g_pHyprOpenGL->m_RenderData.damage = saveDamage;
|
||||
} else {
|
||||
g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, m_pWindow->m_cRealShadowColor.value(), a);
|
||||
g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, PWINDOW->m_cRealShadowColor.value(), a);
|
||||
}
|
||||
|
||||
if (m_seExtents != m_seReportedExtents)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
||||
public:
|
||||
CHyprDropShadowDecoration(CWindow*);
|
||||
CHyprDropShadowDecoration(PHLWINDOW);
|
||||
virtual ~CHyprDropShadowDecoration();
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo();
|
||||
|
|
@ -15,7 +15,7 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
|||
|
||||
virtual eDecorationType getDecorationType();
|
||||
|
||||
virtual void updateWindow(CWindow*);
|
||||
virtual void updateWindow(PHLWINDOW);
|
||||
|
||||
virtual void damageEntire();
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
|||
SWindowDecorationExtents m_seExtents;
|
||||
SWindowDecorationExtents m_seReportedExtents;
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
PHLWINDOWREF m_pWindow;
|
||||
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ constexpr int BAR_PADDING_OUTER_VERT = 2;
|
|||
constexpr int BAR_TEXT_PAD = 2;
|
||||
constexpr int BAR_HORIZONTAL_PADDING = 2;
|
||||
|
||||
CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) : IHyprWindowDecoration(pWindow) {
|
||||
CHyprGroupBarDecoration::CHyprGroupBarDecoration(PHLWINDOW pWindow) : IHyprWindowDecoration(pWindow) {
|
||||
static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:enabled");
|
||||
static auto PENABLED = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
|
||||
m_pWindow = pWindow;
|
||||
|
|
@ -39,7 +39,7 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
|||
info.priority = *PPRIORITY;
|
||||
info.reserved = true;
|
||||
|
||||
if (*PENABLED && m_pWindow->m_sSpecialRenderData.decorate)
|
||||
if (*PENABLED && m_pWindow.lock()->m_sSpecialRenderData.decorate)
|
||||
info.desiredExtents = {{0, BAR_PADDING_OUTER_VERT * 2 + BAR_INDICATOR_HEIGHT + (*PGRADIENTS || *PRENDERTITLES ? *PHEIGHT : 0) + 2}, {0, 0}};
|
||||
else
|
||||
info.desiredExtents = {{0, 0}, {0, 0}};
|
||||
|
|
@ -57,33 +57,33 @@ eDecorationType CHyprGroupBarDecoration::getDecorationType() {
|
|||
|
||||
//
|
||||
|
||||
void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
|
||||
if (!m_pWindow->m_sGroupData.pNextWindow) {
|
||||
m_pWindow->removeWindowDeco(this);
|
||||
void CHyprGroupBarDecoration::updateWindow(PHLWINDOW pWindow) {
|
||||
if (m_pWindow.lock()->m_sGroupData.pNextWindow.expired()) {
|
||||
m_pWindow.lock()->removeWindowDeco(this);
|
||||
return;
|
||||
}
|
||||
|
||||
m_dwGroupMembers.clear();
|
||||
CWindow* head = pWindow->getGroupHead();
|
||||
PHLWINDOW head = pWindow->getGroupHead();
|
||||
m_dwGroupMembers.push_back(head);
|
||||
|
||||
CWindow* curr = head->m_sGroupData.pNextWindow;
|
||||
PHLWINDOW curr = head->m_sGroupData.pNextWindow.lock();
|
||||
while (curr != head) {
|
||||
m_dwGroupMembers.push_back(curr);
|
||||
curr = curr->m_sGroupData.pNextWindow;
|
||||
curr = curr->m_sGroupData.pNextWindow.lock();
|
||||
}
|
||||
|
||||
damageEntire();
|
||||
|
||||
if (m_dwGroupMembers.size() == 0) {
|
||||
m_pWindow->removeWindowDeco(this);
|
||||
m_pWindow.lock()->removeWindowDeco(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CHyprGroupBarDecoration::damageEntire() {
|
||||
auto box = assignedBoxGlobal();
|
||||
box.translate(m_pWindow->m_vFloatingOffset);
|
||||
box.translate(m_pWindow.lock()->m_vFloatingOffset);
|
||||
g_pHyprRenderer->damageBox(&box);
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
static auto PHEIGHT = CConfigValue<Hyprlang::INT>("group:groupbar:height");
|
||||
static auto PGRADIENTS = CConfigValue<Hyprlang::INT>("group:groupbar:gradients");
|
||||
|
||||
if (!*PENABLED || !m_pWindow->m_sSpecialRenderData.decorate)
|
||||
if (!*PENABLED || !m_pWindow.lock()->m_sSpecialRenderData.decorate)
|
||||
return;
|
||||
|
||||
const auto ASSIGNEDBOX = assignedBoxGlobal();
|
||||
|
|
@ -111,8 +111,8 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
int xoff = 0;
|
||||
|
||||
for (int i = 0; i < barsToDraw; ++i) {
|
||||
CBox rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
|
||||
ASSIGNEDBOX.y + ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y, m_fBarWidth,
|
||||
CBox rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow.lock()->m_vFloatingOffset.x,
|
||||
ASSIGNEDBOX.y + ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT - pMonitor->vecPosition.y + m_pWindow.lock()->m_vFloatingOffset.y, m_fBarWidth,
|
||||
BAR_INDICATOR_HEIGHT};
|
||||
|
||||
if (rect.width <= 0 || rect.height <= 0)
|
||||
|
|
@ -129,32 +129,32 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
auto* const GROUPCOLACTIVELOCKED = (CGradientValueData*)(PGROUPCOLACTIVELOCKED.ptr())->getData();
|
||||
auto* const GROUPCOLINACTIVELOCKED = (CGradientValueData*)(PGROUPCOLINACTIVELOCKED.ptr())->getData();
|
||||
|
||||
const bool GROUPLOCKED = m_pWindow->getGroupHead()->m_sGroupData.locked;
|
||||
const bool GROUPLOCKED = m_pWindow.lock()->getGroupHead()->m_sGroupData.locked;
|
||||
const auto* const PCOLACTIVE = GROUPLOCKED ? GROUPCOLACTIVELOCKED : GROUPCOLACTIVE;
|
||||
const auto* const PCOLINACTIVE = GROUPLOCKED ? GROUPCOLINACTIVELOCKED : GROUPCOLINACTIVE;
|
||||
|
||||
CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? PCOLACTIVE->m_vColors[0] : PCOLINACTIVE->m_vColors[0];
|
||||
CColor color = m_dwGroupMembers[i].lock() == g_pCompositor->m_pLastWindow.lock() ? PCOLACTIVE->m_vColors[0] : PCOLINACTIVE->m_vColors[0];
|
||||
color.a *= a;
|
||||
g_pHyprOpenGL->renderRect(&rect, color);
|
||||
|
||||
rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow->m_vFloatingOffset.x,
|
||||
ASSIGNEDBOX.y - pMonitor->vecPosition.y + m_pWindow->m_vFloatingOffset.y + BAR_PADDING_OUTER_VERT, m_fBarWidth,
|
||||
rect = {ASSIGNEDBOX.x + xoff - pMonitor->vecPosition.x + m_pWindow.lock()->m_vFloatingOffset.x,
|
||||
ASSIGNEDBOX.y - pMonitor->vecPosition.y + m_pWindow.lock()->m_vFloatingOffset.y + BAR_PADDING_OUTER_VERT, m_fBarWidth,
|
||||
ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT * 2};
|
||||
rect.scale(pMonitor->scale);
|
||||
|
||||
if (*PGRADIENTS) {
|
||||
const auto& GRADIENTTEX = (m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) :
|
||||
(GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive));
|
||||
const auto& GRADIENTTEX = (m_dwGroupMembers[i].lock() == g_pCompositor->m_pLastWindow.lock() ? (GROUPLOCKED ? m_tGradientLockedActive : m_tGradientActive) :
|
||||
(GROUPLOCKED ? m_tGradientLockedInactive : m_tGradientInactive));
|
||||
if (GRADIENTTEX.m_iTexID != 0)
|
||||
g_pHyprOpenGL->renderTexture(GRADIENTTEX, &rect, 1.0);
|
||||
}
|
||||
|
||||
if (*PRENDERTITLES) {
|
||||
CTitleTex* pTitleTex = textureFromTitle(m_dwGroupMembers[i]->m_szTitle);
|
||||
CTitleTex* pTitleTex = textureFromTitle(m_dwGroupMembers[i].lock()->m_szTitle);
|
||||
|
||||
if (!pTitleTex)
|
||||
pTitleTex = m_sTitleTexs.titleTexs
|
||||
.emplace_back(std::make_unique<CTitleTex>(m_dwGroupMembers[i],
|
||||
.emplace_back(std::make_unique<CTitleTex>(m_dwGroupMembers[i].lock(),
|
||||
Vector2D{m_fBarWidth * pMonitor->scale, (*PTITLEFONTSIZE + 2 * BAR_TEXT_PAD) * pMonitor->scale}))
|
||||
.get();
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ void CHyprGroupBarDecoration::invalidateTextures() {
|
|||
m_sTitleTexs.titleTexs.clear();
|
||||
}
|
||||
|
||||
CTitleTex::CTitleTex(CWindow* pWindow, const Vector2D& bufferSize) {
|
||||
CTitleTex::CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize) {
|
||||
szContent = pWindow->m_szTitle;
|
||||
pWindowOwner = pWindow;
|
||||
const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, bufferSize.x, bufferSize.y);
|
||||
|
|
@ -335,7 +335,7 @@ void refreshGroupBarGradients() {
|
|||
}
|
||||
|
||||
bool CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) {
|
||||
if (m_pWindow == m_pWindow->m_sGroupData.pNextWindow)
|
||||
if (m_pWindow.lock() == m_pWindow.lock()->m_sGroupData.pNextWindow.lock())
|
||||
return false;
|
||||
|
||||
const float BARRELATIVEX = pos.x - assignedBoxGlobal().x;
|
||||
|
|
@ -344,7 +344,7 @@ bool CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) {
|
|||
if (BARRELATIVEX - (m_fBarWidth + BAR_HORIZONTAL_PADDING) * WINDOWINDEX > m_fBarWidth)
|
||||
return false;
|
||||
|
||||
CWindow* pWindow = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||
PHLWINDOW pWindow = m_pWindow.lock()->getGroupWindowByIndex(WINDOWINDEX);
|
||||
|
||||
// hack
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow);
|
||||
|
|
@ -363,33 +363,33 @@ bool CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, CWindow* pDraggedWindow) {
|
||||
if (!pDraggedWindow->canBeGroupedInto(m_pWindow))
|
||||
bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWINDOW pDraggedWindow) {
|
||||
if (!pDraggedWindow->canBeGroupedInto(m_pWindow.lock()))
|
||||
return false;
|
||||
|
||||
const float BARRELATIVEX = pos.x - assignedBoxGlobal().x - m_fBarWidth / 2;
|
||||
const int WINDOWINDEX = BARRELATIVEX < 0 ? -1 : (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
|
||||
|
||||
CWindow* pWindowInsertAfter = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||
CWindow* pWindowInsertEnd = pWindowInsertAfter->m_sGroupData.pNextWindow;
|
||||
CWindow* pDraggedHead = pDraggedWindow->m_sGroupData.pNextWindow ? pDraggedWindow->getGroupHead() : pDraggedWindow;
|
||||
PHLWINDOW pWindowInsertAfter = m_pWindow.lock()->getGroupWindowByIndex(WINDOWINDEX);
|
||||
PHLWINDOW pWindowInsertEnd = pWindowInsertAfter->m_sGroupData.pNextWindow.lock();
|
||||
PHLWINDOW pDraggedHead = pDraggedWindow->m_sGroupData.pNextWindow.lock() ? pDraggedWindow->getGroupHead() : pDraggedWindow;
|
||||
|
||||
if (pDraggedWindow->m_sGroupData.pNextWindow) {
|
||||
if (!pDraggedWindow->m_sGroupData.pNextWindow.expired()) {
|
||||
|
||||
// stores group data
|
||||
std::vector<CWindow*> members;
|
||||
CWindow* curr = pDraggedHead;
|
||||
const bool WASLOCKED = pDraggedHead->m_sGroupData.locked;
|
||||
std::vector<PHLWINDOW> members;
|
||||
PHLWINDOW curr = pDraggedHead;
|
||||
const bool WASLOCKED = pDraggedHead->m_sGroupData.locked;
|
||||
do {
|
||||
members.push_back(curr);
|
||||
curr = curr->m_sGroupData.pNextWindow;
|
||||
curr = curr->m_sGroupData.pNextWindow.lock();
|
||||
} while (curr != members[0]);
|
||||
|
||||
// removes all windows
|
||||
for (CWindow* w : members) {
|
||||
w->m_sGroupData.pNextWindow = nullptr;
|
||||
w->m_sGroupData.head = false;
|
||||
w->m_sGroupData.locked = false;
|
||||
for (PHLWINDOW w : members) {
|
||||
w->m_sGroupData.pNextWindow.reset();
|
||||
w->m_sGroupData.head = false;
|
||||
w->m_sGroupData.locked = false;
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(w);
|
||||
}
|
||||
|
||||
|
|
@ -411,7 +411,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, CWindow
|
|||
if (WINDOWINDEX == -1)
|
||||
std::swap(pDraggedHead->m_sGroupData.head, pWindowInsertEnd->m_sGroupData.head);
|
||||
|
||||
m_pWindow->setGroupCurrent(pDraggedWindow);
|
||||
m_pWindow.lock()->setGroupCurrent(pDraggedWindow);
|
||||
pDraggedWindow->applyGroupRules();
|
||||
pDraggedWindow->updateWindowDecos();
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateWindow(pDraggedWindow);
|
||||
|
|
@ -423,7 +423,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, CWindow
|
|||
}
|
||||
|
||||
bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_pointer_button_event* e) {
|
||||
if (m_pWindow->m_bIsFullscreen && m_pWindow->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL)
|
||||
if (m_pWindow.lock()->m_bIsFullscreen && m_pWindow.lock()->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL)
|
||||
return true;
|
||||
|
||||
const float BARRELATIVEX = pos.x - assignedBoxGlobal().x;
|
||||
|
|
@ -437,7 +437,7 @@ bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_point
|
|||
if (e->state == WL_POINTER_BUTTON_STATE_PRESSED)
|
||||
pressedCursorPos = pos;
|
||||
else if (e->state == WL_POINTER_BUTTON_STATE_RELEASED && pressedCursorPos == pos)
|
||||
g_pXWaylandManager->sendCloseWindow(m_pWindow->getGroupWindowByIndex(WINDOWINDEX));
|
||||
g_pXWaylandManager->sendCloseWindow(m_pWindow.lock()->getGroupWindowByIndex(WINDOWINDEX));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -447,14 +447,14 @@ bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_point
|
|||
|
||||
// click on padding
|
||||
if (BARRELATIVEX - (m_fBarWidth + BAR_HORIZONTAL_PADDING) * WINDOWINDEX > m_fBarWidth) {
|
||||
if (!g_pCompositor->isWindowActive(m_pWindow))
|
||||
g_pCompositor->focusWindow(m_pWindow);
|
||||
if (!g_pCompositor->isWindowActive(m_pWindow.lock()))
|
||||
g_pCompositor->focusWindow(m_pWindow.lock());
|
||||
return true;
|
||||
}
|
||||
|
||||
CWindow* pWindow = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||
PHLWINDOW pWindow = m_pWindow.lock()->getGroupWindowByIndex(WINDOWINDEX);
|
||||
|
||||
if (pWindow != m_pWindow)
|
||||
if (pWindow != m_pWindow.lock())
|
||||
pWindow->setGroupCurrent(pWindow);
|
||||
|
||||
if (!g_pCompositor->isWindowActive(pWindow) && *PFOLLOWMOUSE != 3)
|
||||
|
|
@ -469,13 +469,13 @@ bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_point
|
|||
bool CHyprGroupBarDecoration::onScrollOnDeco(const Vector2D& pos, wlr_pointer_axis_event* e) {
|
||||
static auto PGROUPBARSCROLLING = CConfigValue<Hyprlang::INT>("group:groupbar:scrolling");
|
||||
|
||||
if (!*PGROUPBARSCROLLING || !m_pWindow->m_sGroupData.pNextWindow)
|
||||
if (!*PGROUPBARSCROLLING || m_pWindow.lock()->m_sGroupData.pNextWindow.expired())
|
||||
return false;
|
||||
|
||||
if (e->delta > 0)
|
||||
m_pWindow->setGroupCurrent(m_pWindow->m_sGroupData.pNextWindow);
|
||||
m_pWindow.lock()->setGroupCurrent(m_pWindow.lock()->m_sGroupData.pNextWindow.lock());
|
||||
else
|
||||
m_pWindow->setGroupCurrent(m_pWindow->getGroupPrevious());
|
||||
m_pWindow.lock()->setGroupCurrent(m_pWindow.lock()->getGroupPrevious());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -485,7 +485,7 @@ bool CHyprGroupBarDecoration::onInputOnDeco(const eInputType type, const Vector2
|
|||
case INPUT_TYPE_AXIS: return onScrollOnDeco(mouseCoords, std::any_cast<wlr_pointer_axis_event*>(data));
|
||||
case INPUT_TYPE_BUTTON: return onMouseButtonOnDeco(mouseCoords, std::any_cast<wlr_pointer_button_event*>(data));
|
||||
case INPUT_TYPE_DRAG_START: return onBeginWindowDragOnDeco(mouseCoords);
|
||||
case INPUT_TYPE_DRAG_END: return onEndWindowDragOnDeco(mouseCoords, std::any_cast<CWindow*>(data));
|
||||
case INPUT_TYPE_DRAG_END: return onEndWindowDragOnDeco(mouseCoords, std::any_cast<PHLWINDOW>(data));
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -504,11 +504,11 @@ std::string CHyprGroupBarDecoration::getDisplayName() {
|
|||
|
||||
CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
|
||||
CBox box = m_bAssignedBox;
|
||||
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow));
|
||||
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow.lock()));
|
||||
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
const auto PWORKSPACE = m_pWindow.lock()->m_pWorkspace;
|
||||
|
||||
if (PWORKSPACE && !m_pWindow->m_bPinned)
|
||||
if (PWORKSPACE && !m_pWindow.lock()->m_bPinned)
|
||||
box.translate(PWORKSPACE->m_vRenderOffset.value());
|
||||
|
||||
return box;
|
||||
|
|
|
|||
|
|
@ -8,19 +8,19 @@
|
|||
|
||||
class CTitleTex {
|
||||
public:
|
||||
CTitleTex(CWindow* pWindow, const Vector2D& bufferSize);
|
||||
CTitleTex(PHLWINDOW pWindow, const Vector2D& bufferSize);
|
||||
~CTitleTex();
|
||||
|
||||
CTexture tex;
|
||||
std::string szContent;
|
||||
CWindow* pWindowOwner = nullptr;
|
||||
CTexture tex;
|
||||
std::string szContent;
|
||||
PHLWINDOWREF pWindowOwner;
|
||||
};
|
||||
|
||||
void refreshGroupBarGradients();
|
||||
|
||||
class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
||||
public:
|
||||
CHyprGroupBarDecoration(CWindow*);
|
||||
CHyprGroupBarDecoration(PHLWINDOW);
|
||||
virtual ~CHyprGroupBarDecoration();
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo();
|
||||
|
|
@ -31,7 +31,7 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
|||
|
||||
virtual eDecorationType getDecorationType();
|
||||
|
||||
virtual void updateWindow(CWindow*);
|
||||
virtual void updateWindow(PHLWINDOW);
|
||||
|
||||
virtual void damageEntire();
|
||||
|
||||
|
|
@ -48,9 +48,9 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
|||
|
||||
CBox m_bAssignedBox = {0};
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
PHLWINDOWREF m_pWindow;
|
||||
|
||||
std::deque<CWindow*> m_dwGroupMembers;
|
||||
std::deque<PHLWINDOWREF> m_dwGroupMembers;
|
||||
|
||||
float m_fBarWidth;
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
|||
CBox assignedBoxGlobal();
|
||||
|
||||
bool onBeginWindowDragOnDeco(const Vector2D&);
|
||||
bool onEndWindowDragOnDeco(const Vector2D&, CWindow*);
|
||||
bool onEndWindowDragOnDeco(const Vector2D&, PHLWINDOW);
|
||||
bool onMouseButtonOnDeco(const Vector2D&, wlr_pointer_button_event*);
|
||||
bool onScrollOnDeco(const Vector2D&, wlr_pointer_axis_event*);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@
|
|||
|
||||
CDecorationPositioner::CDecorationPositioner() {
|
||||
static auto P = g_pHookSystem->hookDynamic("closeWindow", [this](void* call, SCallbackInfo& info, std::any data) {
|
||||
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
||||
auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
this->onWindowUnmap(PWINDOW);
|
||||
});
|
||||
|
||||
static auto P2 = g_pHookSystem->hookDynamic("openWindow", [this](void* call, SCallbackInfo& info, std::any data) {
|
||||
auto* const PWINDOW = std::any_cast<CWindow*>(data);
|
||||
auto PWINDOW = std::any_cast<PHLWINDOW>(data);
|
||||
this->onWindowMap(PWINDOW);
|
||||
});
|
||||
}
|
||||
|
||||
Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, CWindow* pWindow) {
|
||||
Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pWindow) {
|
||||
const bool TOP = edges & DECORATION_EDGE_TOP;
|
||||
const bool BOTTOM = edges & DECORATION_EDGE_BOTTOM;
|
||||
const bool LEFT = edges & DECORATION_EDGE_LEFT;
|
||||
|
|
@ -57,9 +57,9 @@ Vector2D CDecorationPositioner::getEdgeDefinedPoint(uint32_t edges, CWindow* pWi
|
|||
}
|
||||
|
||||
void CDecorationPositioner::uncacheDecoration(IHyprWindowDecoration* deco) {
|
||||
std::erase_if(m_vWindowPositioningDatas, [&](const auto& data) { return data->pDecoration == deco; });
|
||||
std::erase_if(m_vWindowPositioningDatas, [&](const auto& data) { return !data->pWindow.lock() || data->pDecoration == deco; });
|
||||
|
||||
const auto WIT = std::find_if(m_mWindowDatas.begin(), m_mWindowDatas.end(), [&](const auto& other) { return other.first == deco->m_pWindow; });
|
||||
const auto WIT = std::find_if(m_mWindowDatas.begin(), m_mWindowDatas.end(), [&](const auto& other) { return other.first.lock() == deco->m_pWindow.lock(); });
|
||||
if (WIT == m_mWindowDatas.end())
|
||||
return;
|
||||
|
||||
|
|
@ -68,10 +68,10 @@ void CDecorationPositioner::uncacheDecoration(IHyprWindowDecoration* deco) {
|
|||
|
||||
void CDecorationPositioner::repositionDeco(IHyprWindowDecoration* deco) {
|
||||
uncacheDecoration(deco);
|
||||
onWindowUpdate(deco->m_pWindow);
|
||||
onWindowUpdate(deco->m_pWindow.lock());
|
||||
}
|
||||
|
||||
CDecorationPositioner::SWindowPositioningData* CDecorationPositioner::getDataFor(IHyprWindowDecoration* pDecoration, CWindow* pWindow) {
|
||||
CDecorationPositioner::SWindowPositioningData* CDecorationPositioner::getDataFor(IHyprWindowDecoration* pDecoration, PHLWINDOW pWindow) {
|
||||
auto it = std::find_if(m_vWindowPositioningDatas.begin(), m_vWindowPositioningDatas.end(), [&](const auto& el) { return el->pDecoration == pDecoration; });
|
||||
|
||||
if (it != m_vWindowPositioningDatas.end())
|
||||
|
|
@ -85,19 +85,19 @@ CDecorationPositioner::SWindowPositioningData* CDecorationPositioner::getDataFor
|
|||
}
|
||||
|
||||
void CDecorationPositioner::sanitizeDatas() {
|
||||
std::erase_if(m_mWindowDatas, [](const auto& other) { return !g_pCompositor->windowExists(other.first); });
|
||||
std::erase_if(m_mWindowDatas, [](const auto& other) { return !valid(other.first); });
|
||||
std::erase_if(m_vWindowPositioningDatas, [](const auto& other) {
|
||||
if (!g_pCompositor->windowExists(other->pWindow))
|
||||
if (!validMapped(other->pWindow))
|
||||
return true;
|
||||
if (std::find_if(other->pWindow->m_dWindowDecorations.begin(), other->pWindow->m_dWindowDecorations.end(),
|
||||
[&](const auto& el) { return el.get() == other->pDecoration; }) == other->pWindow->m_dWindowDecorations.end())
|
||||
if (std::find_if(other->pWindow.lock()->m_dWindowDecorations.begin(), other->pWindow.lock()->m_dWindowDecorations.end(),
|
||||
[&](const auto& el) { return el.get() == other->pDecoration; }) == other->pWindow.lock()->m_dWindowDecorations.end())
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
void CDecorationPositioner::forceRecalcFor(CWindow* pWindow) {
|
||||
const auto WIT = std::find_if(m_mWindowDatas.begin(), m_mWindowDatas.end(), [&](const auto& other) { return other.first == pWindow; });
|
||||
void CDecorationPositioner::forceRecalcFor(PHLWINDOW pWindow) {
|
||||
const auto WIT = std::find_if(m_mWindowDatas.begin(), m_mWindowDatas.end(), [&](const auto& other) { return other.first.lock() == pWindow; });
|
||||
if (WIT == m_mWindowDatas.end())
|
||||
return;
|
||||
|
||||
|
|
@ -106,11 +106,11 @@ void CDecorationPositioner::forceRecalcFor(CWindow* pWindow) {
|
|||
WINDOWDATA->needsRecalc = true;
|
||||
}
|
||||
|
||||
void CDecorationPositioner::onWindowUpdate(CWindow* pWindow) {
|
||||
if (!g_pCompositor->windowExists(pWindow) || !pWindow->m_bIsMapped)
|
||||
void CDecorationPositioner::onWindowUpdate(PHLWINDOW pWindow) {
|
||||
if (!validMapped(pWindow))
|
||||
return;
|
||||
|
||||
const auto WIT = std::find_if(m_mWindowDatas.begin(), m_mWindowDatas.end(), [&](const auto& other) { return other.first == pWindow; });
|
||||
const auto WIT = std::find_if(m_mWindowDatas.begin(), m_mWindowDatas.end(), [&](const auto& other) { return other.first.lock() == pWindow; });
|
||||
if (WIT == m_mWindowDatas.end())
|
||||
return;
|
||||
|
||||
|
|
@ -125,8 +125,8 @@ void CDecorationPositioner::onWindowUpdate(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
if (WINDOWDATA->lastWindowSize == pWindow->m_vRealSize.value() /* position not changed */
|
||||
&&
|
||||
std::all_of(m_vWindowPositioningDatas.begin(), m_vWindowPositioningDatas.end(), [pWindow](const auto& data) { return pWindow != data->pWindow || !data->needsReposition; })
|
||||
&& std::all_of(m_vWindowPositioningDatas.begin(), m_vWindowPositioningDatas.end(),
|
||||
[pWindow](const auto& data) { return pWindow != data->pWindow.lock() || !data->needsReposition; })
|
||||
/* all window datas are either not for this window or don't need a reposition */
|
||||
&& !WINDOWDATA->needsRecalc /* window doesn't need recalc */
|
||||
)
|
||||
|
|
@ -269,30 +269,30 @@ void CDecorationPositioner::onWindowUpdate(CWindow* pWindow) {
|
|||
WINDOWDATA->extents = {{stickyOffsetXL + reservedXL, stickyOffsetYT + reservedYT}, {stickyOffsetXR + reservedXR, stickyOffsetYB + reservedYB}};
|
||||
}
|
||||
|
||||
void CDecorationPositioner::onWindowUnmap(CWindow* pWindow) {
|
||||
std::erase_if(m_vWindowPositioningDatas, [&](const auto& data) { return data->pWindow == pWindow; });
|
||||
void CDecorationPositioner::onWindowUnmap(PHLWINDOW pWindow) {
|
||||
std::erase_if(m_vWindowPositioningDatas, [&](const auto& data) { return data->pWindow.lock() == pWindow; });
|
||||
m_mWindowDatas.erase(pWindow);
|
||||
}
|
||||
|
||||
void CDecorationPositioner::onWindowMap(CWindow* pWindow) {
|
||||
void CDecorationPositioner::onWindowMap(PHLWINDOW pWindow) {
|
||||
m_mWindowDatas[pWindow] = {};
|
||||
}
|
||||
|
||||
SWindowDecorationExtents CDecorationPositioner::getWindowDecorationReserved(CWindow* pWindow) {
|
||||
SWindowDecorationExtents CDecorationPositioner::getWindowDecorationReserved(PHLWINDOW pWindow) {
|
||||
try {
|
||||
const auto E = m_mWindowDatas.at(pWindow);
|
||||
return E.reserved;
|
||||
} catch (std::out_of_range& e) { return {}; }
|
||||
}
|
||||
|
||||
SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(CWindow* pWindow, bool inputOnly) {
|
||||
SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly) {
|
||||
CBox accum = pWindow->getWindowMainSurfaceBox();
|
||||
|
||||
for (auto& data : m_vWindowPositioningDatas) {
|
||||
if (data->pWindow != pWindow)
|
||||
if (data->pWindow.lock() != pWindow)
|
||||
continue;
|
||||
|
||||
if (!data->pWindow || !data->pDecoration)
|
||||
if (!data->pWindow.lock() || !data->pDecoration)
|
||||
continue;
|
||||
|
||||
if (!(data->pDecoration->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT) && inputOnly)
|
||||
|
|
@ -301,7 +301,7 @@ SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(CWind
|
|||
CBox decoBox;
|
||||
|
||||
if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) {
|
||||
decoBox = data->pWindow->getWindowMainSurfaceBox();
|
||||
decoBox = data->pWindow.lock()->getWindowMainSurfaceBox();
|
||||
decoBox.addExtents(data->positioningInfo.desiredExtents);
|
||||
} else {
|
||||
decoBox = data->lastReply.assignedGeometry;
|
||||
|
|
@ -326,11 +326,11 @@ SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(CWind
|
|||
return accum.extentsFrom(pWindow->getWindowMainSurfaceBox());
|
||||
}
|
||||
|
||||
CBox CDecorationPositioner::getBoxWithIncludedDecos(CWindow* pWindow) {
|
||||
CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) {
|
||||
CBox accum = pWindow->getWindowMainSurfaceBox();
|
||||
|
||||
for (auto& data : m_vWindowPositioningDatas) {
|
||||
if (data->pWindow != pWindow)
|
||||
if (data->pWindow.lock() != pWindow)
|
||||
continue;
|
||||
|
||||
if (!(data->pDecoration->getDecorationFlags() & DECORATION_PART_OF_MAIN_WINDOW))
|
||||
|
|
@ -339,7 +339,7 @@ CBox CDecorationPositioner::getBoxWithIncludedDecos(CWindow* pWindow) {
|
|||
CBox decoBox;
|
||||
|
||||
if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) {
|
||||
decoBox = data->pWindow->getWindowMainSurfaceBox();
|
||||
decoBox = data->pWindow.lock()->getWindowMainSurfaceBox();
|
||||
decoBox.addExtents(data->positioningInfo.desiredExtents);
|
||||
} else {
|
||||
decoBox = data->lastReply.assignedGeometry;
|
||||
|
|
@ -365,9 +365,9 @@ CBox CDecorationPositioner::getBoxWithIncludedDecos(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
CBox CDecorationPositioner::getWindowDecorationBox(IHyprWindowDecoration* deco) {
|
||||
const auto DATA = getDataFor(deco, deco->m_pWindow);
|
||||
const auto DATA = getDataFor(deco, deco->m_pWindow.lock());
|
||||
|
||||
CBox box = DATA->lastReply.assignedGeometry;
|
||||
box.translate(getEdgeDefinedPoint(DATA->positioningInfo.edges, deco->m_pWindow));
|
||||
box.translate(getEdgeDefinedPoint(DATA->positioningInfo.edges, deco->m_pWindow.lock()));
|
||||
return box;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@
|
|||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <map>
|
||||
#include "../../helpers/Box.hpp"
|
||||
|
||||
class CWindow;
|
||||
class IHyprWindowDecoration;
|
||||
|
||||
typedef std::shared_ptr<CWindow> PHLWINDOW;
|
||||
typedef std::weak_ptr<CWindow> PHLWINDOWREF;
|
||||
|
||||
enum eDecorationPositioningPolicy {
|
||||
DECORATION_POSITION_ABSOLUTE = 0, /* Decoration wants absolute positioning */
|
||||
DECORATION_POSITION_STICKY, /* Decoration is stuck to some edge of a window */
|
||||
|
|
@ -59,21 +62,21 @@ class CDecorationPositioner {
|
|||
public:
|
||||
CDecorationPositioner();
|
||||
|
||||
Vector2D getEdgeDefinedPoint(uint32_t edges, CWindow* pWindow);
|
||||
Vector2D getEdgeDefinedPoint(uint32_t edges, PHLWINDOW pWindow);
|
||||
|
||||
// called on resize, or insert/removal of a new deco
|
||||
void onWindowUpdate(CWindow* pWindow);
|
||||
void onWindowUpdate(PHLWINDOW pWindow);
|
||||
void uncacheDecoration(IHyprWindowDecoration* deco);
|
||||
SWindowDecorationExtents getWindowDecorationReserved(CWindow* pWindow);
|
||||
SWindowDecorationExtents getWindowDecorationExtents(CWindow* pWindow, bool inputOnly = false);
|
||||
CBox getBoxWithIncludedDecos(CWindow* pWindow);
|
||||
SWindowDecorationExtents getWindowDecorationReserved(PHLWINDOW pWindow);
|
||||
SWindowDecorationExtents getWindowDecorationExtents(PHLWINDOW pWindow, bool inputOnly = false);
|
||||
CBox getBoxWithIncludedDecos(PHLWINDOW pWindow);
|
||||
void repositionDeco(IHyprWindowDecoration* deco);
|
||||
CBox getWindowDecorationBox(IHyprWindowDecoration* deco);
|
||||
void forceRecalcFor(CWindow* pWindow);
|
||||
void forceRecalcFor(PHLWINDOW pWindow);
|
||||
|
||||
private:
|
||||
struct SWindowPositioningData {
|
||||
CWindow* pWindow = nullptr;
|
||||
PHLWINDOWREF pWindow;
|
||||
IHyprWindowDecoration* pDecoration = nullptr;
|
||||
SDecorationPositioningInfo positioningInfo;
|
||||
SDecorationPositioningReply lastReply;
|
||||
|
|
@ -87,13 +90,13 @@ class CDecorationPositioner {
|
|||
bool needsRecalc = false;
|
||||
};
|
||||
|
||||
std::unordered_map<CWindow*, SWindowData> m_mWindowDatas;
|
||||
std::vector<std::unique_ptr<SWindowPositioningData>> m_vWindowPositioningDatas;
|
||||
std::map<PHLWINDOWREF, SWindowData, std::owner_less<PHLWINDOWREF>> m_mWindowDatas;
|
||||
std::vector<std::unique_ptr<SWindowPositioningData>> m_vWindowPositioningDatas;
|
||||
|
||||
SWindowPositioningData* getDataFor(IHyprWindowDecoration* pDecoration, CWindow* pWindow);
|
||||
void onWindowUnmap(CWindow* pWindow);
|
||||
void onWindowMap(CWindow* pWindow);
|
||||
void sanitizeDatas();
|
||||
SWindowPositioningData* getDataFor(IHyprWindowDecoration* pDecoration, PHLWINDOW pWindow);
|
||||
void onWindowUnmap(PHLWINDOW pWindow);
|
||||
void onWindowMap(PHLWINDOW pWindow);
|
||||
void sanitizeDatas();
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CDecorationPositioner> g_pDecorationPositioner;
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class CWindow;
|
||||
|
||||
IHyprWindowDecoration::IHyprWindowDecoration(CWindow* pWindow) {
|
||||
IHyprWindowDecoration::IHyprWindowDecoration(PHLWINDOW pWindow) {
|
||||
m_pWindow = pWindow;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class CDecorationPositioner;
|
|||
|
||||
class IHyprWindowDecoration {
|
||||
public:
|
||||
IHyprWindowDecoration(CWindow*);
|
||||
IHyprWindowDecoration(PHLWINDOW);
|
||||
virtual ~IHyprWindowDecoration() = 0;
|
||||
|
||||
virtual SDecorationPositioningInfo getPositioningInfo() = 0;
|
||||
|
|
@ -43,7 +43,7 @@ class IHyprWindowDecoration {
|
|||
|
||||
virtual eDecorationType getDecorationType() = 0;
|
||||
|
||||
virtual void updateWindow(CWindow*) = 0;
|
||||
virtual void updateWindow(PHLWINDOW) = 0;
|
||||
|
||||
virtual void damageEntire() = 0; // should be ignored by non-absolute decos
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ class IHyprWindowDecoration {
|
|||
virtual std::string getDisplayName();
|
||||
|
||||
private:
|
||||
CWindow* m_pWindow = nullptr;
|
||||
PHLWINDOWREF m_pWindow;
|
||||
|
||||
friend class CDecorationPositioner;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue