From e5f22c06b4c01784753315156247e15d0ec3db45 Mon Sep 17 00:00:00 2001 From: UjinT34 <41110182+UjinT34@users.noreply.github.com> Date: Sat, 27 Dec 2025 21:17:51 +0300 Subject: [PATCH] master: fix placement with center_ignores_reserved (#12695) --- src/layout/MasterLayout.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index d677d7b6..8c6376ab 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -349,10 +349,11 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) { static auto PIGNORERESERVED = CConfigValue("master:center_ignores_reserved"); static auto PSMARTRESIZING = CConfigValue("master:smart_resizing"); - const auto MASTERS = getMastersOnWorkspace(pWorkspace->m_id); - const auto WINDOWS = getNodesOnWorkspace(pWorkspace->m_id); - const auto STACKWINDOWS = WINDOWS - MASTERS; - const auto WORKAREA = workAreaOnWorkspace(pWorkspace); + const auto MASTERS = getMastersOnWorkspace(pWorkspace->m_id); + const auto WINDOWS = getNodesOnWorkspace(pWorkspace->m_id); + const auto STACKWINDOWS = WINDOWS - MASTERS; + const auto WORKAREA = workAreaOnWorkspace(pWorkspace); + const auto UNRESERVED_WIDTH = WORKAREA.width + PMONITOR->m_reservedArea.left() + PMONITOR->m_reservedArea.right(); if (orientation == ORIENTATION_CENTER) { if (STACKWINDOWS >= *SLAVECOUNTFORCENTER) @@ -443,11 +444,12 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) { nextX += WIDTH; } } else { // orientation left, right or center - float WIDTH = *PIGNORERESERVED && centerMasterWindow ? PMONITOR->m_size.x : WORKAREA.w; - float heightLeft = WORKAREA.h; - int mastersLeft = MASTERS; - float nextX = 0; - float nextY = 0; + const float TOTAL_WIDTH = *PIGNORERESERVED && centerMasterWindow ? UNRESERVED_WIDTH : WORKAREA.w; + float WIDTH = TOTAL_WIDTH; + float heightLeft = WORKAREA.h; + int mastersLeft = MASTERS; + float nextX = 0; + float nextY = 0; if (STACKWINDOWS > 0 || centerMasterWindow) WIDTH *= PMASTERNODE->percMaster; @@ -455,7 +457,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) { if (orientation == ORIENTATION_RIGHT) nextX = WORKAREA.w - WIDTH; else if (centerMasterWindow) - nextX = ((*PIGNORERESERVED && centerMasterWindow ? PMONITOR->m_size.x : WORKAREA.w) - WIDTH) / 2; + nextX += (TOTAL_WIDTH - WIDTH) / 2; for (auto& nd : m_masterNodesData) { if (nd.workspaceID != pWorkspace->m_id || !nd.isMaster) @@ -471,7 +473,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) { } nd.size = Vector2D(WIDTH, HEIGHT); - nd.position = (*PIGNORERESERVED && centerMasterWindow ? PMONITOR->m_position : WORKAREA.pos()) + Vector2D(nextX, nextY); + nd.position = (*PIGNORERESERVED && centerMasterWindow ? WORKAREA.pos() - Vector2D(PMONITOR->m_reservedArea.left(), 0.0) : WORKAREA.pos()) + Vector2D(nextX, nextY); applyNodeDataToWindow(&nd); mastersLeft--; @@ -546,7 +548,7 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) { nextY += HEIGHT; } } else { // slaves for centered master window(s) - const float WIDTH = ((*PIGNORERESERVED ? PMONITOR->m_size.x : WORKAREA.w) - PMASTERNODE->size.x) / 2.0; + const float WIDTH = ((*PIGNORERESERVED ? UNRESERVED_WIDTH : WORKAREA.w) - PMASTERNODE->size.x) / 2.0; float heightLeft = 0; float heightLeftL = WORKAREA.h; float heightLeftR = WORKAREA.h;