From 7055d0c138965679bb88ed4db60e2698db66bbf9 Mon Sep 17 00:00:00 2001 From: nyx Date: Thu, 6 Mar 2025 17:06:05 -0500 Subject: master: add option to keep master window position (#9537) --- src/layout/MasterLayout.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/layout/MasterLayout.cpp') diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index a429843f..59a5b14f 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -374,8 +374,22 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) { // compute placement of master window(s) if (WINDOWS == 1 && !centerMasterWindow) { - PMASTERNODE->size = WSSIZE; - PMASTERNODE->position = WSPOS; + static auto PALWAYSKEEPPOSITION = CConfigValue("master:always_keep_position"); + if (*PALWAYSKEEPPOSITION) { + const float WIDTH = WSSIZE.x * PMASTERNODE->percMaster; + float nextX = 0; + + if (orientation == ORIENTATION_RIGHT) + nextX = WSSIZE.x - WIDTH; + else if (orientation == ORIENTATION_CENTER) + nextX = (WSSIZE.x - WIDTH) / 2; + + PMASTERNODE->size = Vector2D(WIDTH, WSSIZE.y); + PMASTERNODE->position = WSPOS + Vector2D((double)nextX, 0.0); + } else { + PMASTERNODE->size = WSSIZE; + PMASTERNODE->position = WSPOS; + } applyNodeDataToWindow(PMASTERNODE); return; -- cgit v1.2.3