internal: new shared_ptr and weak_ptr implementation (#5883)
moves std::shared_ptrs to a new implementation Advantages: - you can dereference a weak_ptr directly. This will obviously segfault on a nullptr deref if it's expired. - this is useful to avoid the .lock() hell where we are 100% sure the pointer _should_ be valid. (and if it isn't, it should throw.) - weak_ptrs are still valid while the SP is being destroyed. - reasoning: while an object (e.g. CWindow) is being destroyed, its `weak_ptr self` should be accessible (the sp is still alive, and so is CWindow), but it's not because by stl it's already expired (to prevent resurrection) - this impl solves it differently. w_p is expired, but can still be dereferenced and used. Creating `s_p`s is not possible anymore, though. - this is useful in destructors and callbacks.
This commit is contained in:
parent
589f758d94
commit
1ed1ce9506
88 changed files with 899 additions and 414 deletions
|
|
@ -874,7 +874,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, CBox*
|
|||
}
|
||||
}
|
||||
|
||||
if (m_pCurrentWindow.lock() && m_pCurrentWindow.lock()->m_sAdditionalConfigData.forceRGBX)
|
||||
if (m_pCurrentWindow.lock() && m_pCurrentWindow->m_sAdditionalConfigData.forceRGBX)
|
||||
shader = &m_RenderData.pCurrentMonData->m_shRGBX;
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
|
@ -943,7 +943,7 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, CBox*
|
|||
|
||||
if (allowDim && m_pCurrentWindow.lock() && *PDIMINACTIVE) {
|
||||
glUniform1i(shader->applyTint, 1);
|
||||
const auto DIM = m_pCurrentWindow.lock()->m_fDimPercent.value();
|
||||
const auto DIM = m_pCurrentWindow->m_fDimPercent.value();
|
||||
glUniform3f(shader->tint, 1.f - DIM, 1.f - DIM, 1.f - DIM);
|
||||
} else {
|
||||
glUniform1i(shader->applyTint, 0);
|
||||
|
|
@ -1494,7 +1494,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, CBox* pBox, flo
|
|||
m_RenderData.renderModif.applyToRegion(texDamage);
|
||||
|
||||
if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) ||
|
||||
(m_pCurrentWindow.lock() && (m_pCurrentWindow.lock()->m_sAdditionalConfigData.forceNoBlur || m_pCurrentWindow.lock()->m_sAdditionalConfigData.forceRGBX))) {
|
||||
(m_pCurrentWindow.lock() && (m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur || m_pCurrentWindow->m_sAdditionalConfigData.forceRGBX))) {
|
||||
renderTexture(tex, pBox, a, round, false, true);
|
||||
return;
|
||||
}
|
||||
|
|
@ -1591,7 +1591,7 @@ void CHyprOpenGLImpl::renderBorder(CBox* box, const CGradientValueData& grad, in
|
|||
|
||||
TRACY_GPU_ZONE("RenderBorder");
|
||||
|
||||
if (m_RenderData.damage.empty() || (m_pCurrentWindow.lock() && m_pCurrentWindow.lock()->m_sAdditionalConfigData.forceNoBorder))
|
||||
if (m_RenderData.damage.empty() || (m_pCurrentWindow.lock() && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBorder))
|
||||
return;
|
||||
|
||||
CBox newBox = *box;
|
||||
|
|
|
|||
|
|
@ -196,10 +196,10 @@ class CHyprOpenGLImpl {
|
|||
PHLWINDOWREF m_pCurrentWindow; // hack to get the current rendered window
|
||||
PHLLS m_pCurrentLayer; // hack to get the current rendered layer
|
||||
|
||||
std::map<PHLWINDOWREF, CFramebuffer, std::owner_less<PHLWINDOWREF>> m_mWindowFramebuffers;
|
||||
std::map<PHLLSREF, CFramebuffer, std::owner_less<PHLLSREF>> m_mLayerFramebuffers;
|
||||
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
|
||||
std::unordered_map<CMonitor*, CFramebuffer> m_mMonitorBGFBs;
|
||||
std::map<PHLWINDOWREF, CFramebuffer> m_mWindowFramebuffers;
|
||||
std::map<PHLLSREF, CFramebuffer> m_mLayerFramebuffers;
|
||||
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
|
||||
std::unordered_map<CMonitor*, CFramebuffer> m_mMonitorBGFBs;
|
||||
|
||||
struct {
|
||||
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES = nullptr;
|
||||
|
|
|
|||
|
|
@ -417,7 +417,7 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor
|
|||
continue;
|
||||
|
||||
// render active window after all others of this pass
|
||||
if (w == g_pCompositor->m_pLastWindow.lock()) {
|
||||
if (w == g_pCompositor->m_pLastWindow) {
|
||||
lastWindow = w;
|
||||
continue;
|
||||
}
|
||||
|
|
@ -740,12 +740,12 @@ void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, CMon
|
|||
SRenderData renderdata = {pMonitor, time, pMonitor->vecPosition.x, pMonitor->vecPosition.y};
|
||||
|
||||
renderdata.blur = false;
|
||||
renderdata.surface = pSurface->surface.lock()->surface();
|
||||
renderdata.surface = pSurface->surface->surface();
|
||||
renderdata.decorate = false;
|
||||
renderdata.w = pMonitor->vecSize.x;
|
||||
renderdata.h = pMonitor->vecSize.y;
|
||||
|
||||
wlr_surface_for_each_surface(pSurface->surface.lock()->surface(), renderSurface, &renderdata);
|
||||
wlr_surface_for_each_surface(pSurface->surface->surface(), renderSurface, &renderdata);
|
||||
}
|
||||
|
||||
void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time, const Vector2D& translate, const float& scale) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ CHyprBorderDecoration::~CHyprBorderDecoration() {
|
|||
}
|
||||
|
||||
SDecorationPositioningInfo CHyprBorderDecoration::getPositioningInfo() {
|
||||
const auto BORDERSIZE = m_pWindow.lock()->getRealBorderSize();
|
||||
const auto BORDERSIZE = m_pWindow->getRealBorderSize();
|
||||
m_seExtents = {{BORDERSIZE, BORDERSIZE}, {BORDERSIZE, BORDERSIZE}};
|
||||
|
||||
if (doesntWantBorders())
|
||||
|
|
@ -36,12 +36,12 @@ 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.lock()));
|
||||
|
||||
const auto PWORKSPACE = m_pWindow.lock()->m_pWorkspace;
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
|
||||
if (!PWORKSPACE)
|
||||
return box;
|
||||
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow.lock()->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
const auto WORKSPACEOFFSET = PWORKSPACE && !m_pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.value() : Vector2D();
|
||||
return box.translate(WORKSPACEOFFSET);
|
||||
}
|
||||
|
||||
|
|
@ -52,29 +52,28 @@ 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.lock()->m_vFloatingOffset).expand(-m_pWindow.lock()->getRealBorderSize()).scale(pMonitor->scale).round();
|
||||
CBox windowBox = assignedBoxGlobal().translate(-pMonitor->vecPosition + m_pWindow->m_vFloatingOffset).expand(-m_pWindow->getRealBorderSize()).scale(pMonitor->scale).round();
|
||||
|
||||
if (windowBox.width < 1 || windowBox.height < 1)
|
||||
return;
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
if (m_pWindow.lock()->m_fBorderAngleAnimationProgress.getConfig()->pValues->internalEnabled) {
|
||||
grad.m_fAngle += m_pWindow.lock()->m_fBorderAngleAnimationProgress.value() * M_PI * 2;
|
||||
if (m_pWindow->m_fBorderAngleAnimationProgress.getConfig()->pValues->internalEnabled) {
|
||||
grad.m_fAngle += m_pWindow->m_fBorderAngleAnimationProgress.value() * M_PI * 2;
|
||||
grad.m_fAngle = normalizeAngleRad(grad.m_fAngle);
|
||||
}
|
||||
|
||||
int borderSize = m_pWindow.lock()->getRealBorderSize();
|
||||
const auto ROUNDING = m_pWindow.lock()->rounding() * pMonitor->scale;
|
||||
int borderSize = m_pWindow->getRealBorderSize();
|
||||
const auto ROUNDING = m_pWindow->rounding() * pMonitor->scale;
|
||||
|
||||
g_pHyprOpenGL->renderBorder(&windowBox, grad, ROUNDING, borderSize, a1);
|
||||
|
||||
if (ANIMATED) {
|
||||
float a2 = a * (1.f - m_pWindow.lock()->m_fBorderFadeAnimationProgress.value());
|
||||
g_pHyprOpenGL->renderBorder(&windowBox, m_pWindow.lock()->m_cRealBorderColorPrevious, ROUNDING, borderSize, a2);
|
||||
float a2 = a * (1.f - m_pWindow->m_fBorderFadeAnimationProgress.value());
|
||||
g_pHyprOpenGL->renderBorder(&windowBox, m_pWindow->m_cRealBorderColorPrevious, ROUNDING, borderSize, a2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +82,7 @@ eDecorationType CHyprBorderDecoration::getDecorationType() {
|
|||
}
|
||||
|
||||
void CHyprBorderDecoration::updateWindow(PHLWINDOW) {
|
||||
if (m_pWindow.lock()->getRealBorderSize() != m_seExtents.topLeft.x)
|
||||
if (m_pWindow->getRealBorderSize() != m_seExtents.topLeft.x)
|
||||
g_pDecorationPositioner->repositionDeco(this);
|
||||
}
|
||||
|
||||
|
|
@ -91,15 +90,15 @@ void CHyprBorderDecoration::damageEntire() {
|
|||
if (!validMapped(m_pWindow))
|
||||
return;
|
||||
|
||||
auto surfaceBox = m_pWindow.lock()->getWindowMainSurfaceBox();
|
||||
const auto ROUNDING = m_pWindow.lock()->rounding();
|
||||
auto surfaceBox = m_pWindow->getWindowMainSurfaceBox();
|
||||
const auto ROUNDING = m_pWindow->rounding();
|
||||
const auto ROUNDINGSIZE = ROUNDING - M_SQRT1_2 * ROUNDING + 2;
|
||||
const auto BORDERSIZE = m_pWindow.lock()->getRealBorderSize() + 1;
|
||||
const auto BORDERSIZE = m_pWindow->getRealBorderSize() + 1;
|
||||
|
||||
const auto PWINDOWWORKSPACE = m_pWindow.lock()->m_pWorkspace;
|
||||
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow.lock()->m_bPinned)
|
||||
const auto PWINDOWWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
if (PWINDOWWORKSPACE && PWINDOWWORKSPACE->m_vRenderOffset.isBeingAnimated() && !m_pWindow->m_bPinned)
|
||||
surfaceBox.translate(PWINDOWWORKSPACE->m_vRenderOffset.value());
|
||||
surfaceBox.translate(m_pWindow.lock()->m_vFloatingOffset);
|
||||
surfaceBox.translate(m_pWindow->m_vFloatingOffset);
|
||||
|
||||
CBox surfaceBoxExpandedBorder = surfaceBox;
|
||||
surfaceBoxExpandedBorder.expand(BORDERSIZE);
|
||||
|
|
@ -134,5 +133,5 @@ std::string CHyprBorderDecoration::getDisplayName() {
|
|||
}
|
||||
|
||||
bool CHyprBorderDecoration::doesntWantBorders() {
|
||||
return !m_pWindow.lock()->m_sSpecialRenderData.border || m_pWindow.lock()->m_bX11DoesntWantBorders || m_pWindow.lock()->getRealBorderSize() == 0;
|
||||
return !m_pWindow->m_sSpecialRenderData.border || m_pWindow->m_bX11DoesntWantBorders || m_pWindow->getRealBorderSize() == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ SDecorationPositioningInfo CHyprGroupBarDecoration::getPositioningInfo() {
|
|||
info.priority = *PPRIORITY;
|
||||
info.reserved = true;
|
||||
|
||||
if (*PENABLED && m_pWindow.lock()->m_sSpecialRenderData.decorate)
|
||||
if (*PENABLED && m_pWindow->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}};
|
||||
|
|
@ -58,8 +58,8 @@ eDecorationType CHyprGroupBarDecoration::getDecorationType() {
|
|||
//
|
||||
|
||||
void CHyprGroupBarDecoration::updateWindow(PHLWINDOW pWindow) {
|
||||
if (m_pWindow.lock()->m_sGroupData.pNextWindow.expired()) {
|
||||
m_pWindow.lock()->removeWindowDeco(this);
|
||||
if (m_pWindow->m_sGroupData.pNextWindow.expired()) {
|
||||
m_pWindow->removeWindowDeco(this);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -76,14 +76,14 @@ void CHyprGroupBarDecoration::updateWindow(PHLWINDOW pWindow) {
|
|||
damageEntire();
|
||||
|
||||
if (m_dwGroupMembers.size() == 0) {
|
||||
m_pWindow.lock()->removeWindowDeco(this);
|
||||
m_pWindow->removeWindowDeco(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CHyprGroupBarDecoration::damageEntire() {
|
||||
auto box = assignedBoxGlobal();
|
||||
box.translate(m_pWindow.lock()->m_vFloatingOffset);
|
||||
box.translate(m_pWindow->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.lock()->m_sSpecialRenderData.decorate)
|
||||
if (!*PENABLED || !m_pWindow->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.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,
|
||||
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,
|
||||
BAR_INDICATOR_HEIGHT};
|
||||
|
||||
if (rect.width <= 0 || rect.height <= 0)
|
||||
|
|
@ -129,7 +129,7 @@ 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.lock()->getGroupHead()->m_sGroupData.locked;
|
||||
const bool GROUPLOCKED = m_pWindow->getGroupHead()->m_sGroupData.locked;
|
||||
const auto* const PCOLACTIVE = GROUPLOCKED ? GROUPCOLACTIVELOCKED : GROUPCOLACTIVE;
|
||||
const auto* const PCOLINACTIVE = GROUPLOCKED ? GROUPCOLINACTIVELOCKED : GROUPCOLINACTIVE;
|
||||
|
||||
|
|
@ -137,8 +137,8 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
color.a *= a;
|
||||
g_pHyprOpenGL->renderRect(&rect, color);
|
||||
|
||||
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,
|
||||
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,
|
||||
ASSIGNEDBOX.h - BAR_INDICATOR_HEIGHT - BAR_PADDING_OUTER_VERT * 2};
|
||||
rect.scale(pMonitor->scale);
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) {
|
|||
}
|
||||
|
||||
if (*PRENDERTITLES) {
|
||||
CTitleTex* pTitleTex = textureFromTitle(m_dwGroupMembers[i].lock()->m_szTitle);
|
||||
CTitleTex* pTitleTex = textureFromTitle(m_dwGroupMembers[i]->m_szTitle);
|
||||
|
||||
if (!pTitleTex)
|
||||
pTitleTex = m_sTitleTexs.titleTexs
|
||||
|
|
@ -335,7 +335,7 @@ void refreshGroupBarGradients() {
|
|||
}
|
||||
|
||||
bool CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) {
|
||||
if (m_pWindow.lock() == m_pWindow.lock()->m_sGroupData.pNextWindow.lock())
|
||||
if (m_pWindow.lock() == m_pWindow->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;
|
||||
|
||||
PHLWINDOW pWindow = m_pWindow.lock()->getGroupWindowByIndex(WINDOWINDEX);
|
||||
PHLWINDOW pWindow = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||
|
||||
// hack
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(pWindow);
|
||||
|
|
@ -370,7 +370,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND
|
|||
const float BARRELATIVEX = pos.x - assignedBoxGlobal().x - m_fBarWidth / 2;
|
||||
const int WINDOWINDEX = BARRELATIVEX < 0 ? -1 : (BARRELATIVEX) / (m_fBarWidth + BAR_HORIZONTAL_PADDING);
|
||||
|
||||
PHLWINDOW pWindowInsertAfter = m_pWindow.lock()->getGroupWindowByIndex(WINDOWINDEX);
|
||||
PHLWINDOW pWindowInsertAfter = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||
PHLWINDOW pWindowInsertEnd = pWindowInsertAfter->m_sGroupData.pNextWindow.lock();
|
||||
PHLWINDOW pDraggedHead = pDraggedWindow->m_sGroupData.pNextWindow.lock() ? pDraggedWindow->getGroupHead() : pDraggedWindow;
|
||||
|
||||
|
|
@ -411,7 +411,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND
|
|||
if (WINDOWINDEX == -1)
|
||||
std::swap(pDraggedHead->m_sGroupData.head, pWindowInsertEnd->m_sGroupData.head);
|
||||
|
||||
m_pWindow.lock()->setGroupCurrent(pDraggedWindow);
|
||||
m_pWindow->setGroupCurrent(pDraggedWindow);
|
||||
pDraggedWindow->applyGroupRules();
|
||||
pDraggedWindow->updateWindowDecos();
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateWindow(pDraggedWindow);
|
||||
|
|
@ -423,7 +423,7 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND
|
|||
}
|
||||
|
||||
bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_pointer_button_event* e) {
|
||||
if (m_pWindow.lock()->m_bIsFullscreen && m_pWindow.lock()->m_pWorkspace->m_efFullscreenMode == FULLSCREEN_FULL)
|
||||
if (m_pWindow->m_bIsFullscreen && m_pWindow->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.lock()->getGroupWindowByIndex(WINDOWINDEX));
|
||||
g_pXWaylandManager->sendCloseWindow(m_pWindow->getGroupWindowByIndex(WINDOWINDEX));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -452,9 +452,9 @@ bool CHyprGroupBarDecoration::onMouseButtonOnDeco(const Vector2D& pos, wlr_point
|
|||
return true;
|
||||
}
|
||||
|
||||
PHLWINDOW pWindow = m_pWindow.lock()->getGroupWindowByIndex(WINDOWINDEX);
|
||||
PHLWINDOW pWindow = m_pWindow->getGroupWindowByIndex(WINDOWINDEX);
|
||||
|
||||
if (pWindow != m_pWindow.lock())
|
||||
if (pWindow != m_pWindow)
|
||||
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.lock()->m_sGroupData.pNextWindow.expired())
|
||||
if (!*PGROUPBARSCROLLING || m_pWindow->m_sGroupData.pNextWindow.expired())
|
||||
return false;
|
||||
|
||||
if (e->delta > 0)
|
||||
m_pWindow.lock()->setGroupCurrent(m_pWindow.lock()->m_sGroupData.pNextWindow.lock());
|
||||
m_pWindow->setGroupCurrent(m_pWindow->m_sGroupData.pNextWindow.lock());
|
||||
else
|
||||
m_pWindow.lock()->setGroupCurrent(m_pWindow.lock()->getGroupPrevious());
|
||||
m_pWindow->setGroupCurrent(m_pWindow->getGroupPrevious());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -506,9 +506,9 @@ CBox CHyprGroupBarDecoration::assignedBoxGlobal() {
|
|||
CBox box = m_bAssignedBox;
|
||||
box.translate(g_pDecorationPositioner->getEdgeDefinedPoint(DECORATION_EDGE_TOP, m_pWindow.lock()));
|
||||
|
||||
const auto PWORKSPACE = m_pWindow.lock()->m_pWorkspace;
|
||||
const auto PWORKSPACE = m_pWindow->m_pWorkspace;
|
||||
|
||||
if (PWORKSPACE && !m_pWindow.lock()->m_bPinned)
|
||||
if (PWORKSPACE && !m_pWindow->m_bPinned)
|
||||
box.translate(PWORKSPACE->m_vRenderOffset.value());
|
||||
|
||||
return box;
|
||||
|
|
|
|||
|
|
@ -85,12 +85,17 @@ CDecorationPositioner::SWindowPositioningData* CDecorationPositioner::getDataFor
|
|||
}
|
||||
|
||||
void CDecorationPositioner::sanitizeDatas() {
|
||||
std::erase_if(m_mWindowDatas, [](const auto& other) { return !valid(other.first); });
|
||||
std::erase_if(m_mWindowDatas, [](const auto& other) {
|
||||
if (!valid(other.first))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
std::erase_if(m_vWindowPositioningDatas, [](const auto& other) {
|
||||
if (!validMapped(other->pWindow))
|
||||
return true;
|
||||
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())
|
||||
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())
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
|
|
@ -302,7 +307,7 @@ SWindowDecorationExtents CDecorationPositioner::getWindowDecorationExtents(PHLWI
|
|||
CBox decoBox;
|
||||
|
||||
if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) {
|
||||
decoBox = data->pWindow.lock()->getWindowMainSurfaceBox();
|
||||
decoBox = data->pWindow->getWindowMainSurfaceBox();
|
||||
decoBox.addExtents(data->positioningInfo.desiredExtents);
|
||||
} else {
|
||||
decoBox = data->lastReply.assignedGeometry;
|
||||
|
|
@ -340,7 +345,7 @@ CBox CDecorationPositioner::getBoxWithIncludedDecos(PHLWINDOW pWindow) {
|
|||
CBox decoBox;
|
||||
|
||||
if (data->positioningInfo.policy == DECORATION_POSITION_ABSOLUTE) {
|
||||
decoBox = data->pWindow.lock()->getWindowMainSurfaceBox();
|
||||
decoBox = data->pWindow->getWindowMainSurfaceBox();
|
||||
decoBox.addExtents(data->positioningInfo.desiredExtents);
|
||||
} else {
|
||||
decoBox = data->lastReply.assignedGeometry;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "../../helpers/Box.hpp"
|
||||
#include "../../desktop/DesktopTypes.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 */
|
||||
|
|
@ -90,13 +87,13 @@ class CDecorationPositioner {
|
|||
bool needsRecalc = false;
|
||||
};
|
||||
|
||||
std::map<PHLWINDOWREF, SWindowData, std::owner_less<PHLWINDOWREF>> m_mWindowDatas;
|
||||
std::vector<std::unique_ptr<SWindowPositioningData>> m_vWindowPositioningDatas;
|
||||
std::map<PHLWINDOWREF, SWindowData> m_mWindowDatas;
|
||||
std::vector<std::unique_ptr<SWindowPositioningData>> m_vWindowPositioningDatas;
|
||||
|
||||
SWindowPositioningData* getDataFor(IHyprWindowDecoration* pDecoration, PHLWINDOW pWindow);
|
||||
void onWindowUnmap(PHLWINDOW pWindow);
|
||||
void onWindowMap(PHLWINDOW 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue