summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornyx <nnyyxxxx@protonmail.com>2025-03-06 17:06:05 -0500
committerGitHub <noreply@github.com>2025-03-06 23:06:05 +0100
commit7055d0c138965679bb88ed4db60e2698db66bbf9 (patch)
tree4bf0ecb4b57e4e8fb294ba5c755ec57628826580 /src
parent4435f5c5463978ea689e6b4aa30e455e061a80ad (diff)
master: add option to keep master window position (#9537)
Diffstat (limited to 'src')
-rw-r--r--src/config/ConfigDescriptions.hpp6
-rw-r--r--src/config/ConfigManager.cpp1
-rw-r--r--src/layout/MasterLayout.cpp18
3 files changed, 23 insertions, 2 deletions
diff --git a/src/config/ConfigDescriptions.hpp b/src/config/ConfigDescriptions.hpp
index 7ed0d03c..690d2e93 100644
--- a/src/config/ConfigDescriptions.hpp
+++ b/src/config/ConfigDescriptions.hpp
@@ -1770,4 +1770,10 @@ inline static const std::vector<SConfigOptionDescription> CONFIG_OPTIONS = {
.type = CONFIG_OPTION_BOOL,
.data = SConfigOptionDescription::SBoolData{false},
},
+ SConfigOptionDescription{
+ .value = "master:always_keep_position",
+ .description = "whether to keep the master window in its configured position when there are no slave windows",
+ .type = CONFIG_OPTION_BOOL,
+ .data = SConfigOptionDescription::SBoolData{false},
+ },
};
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index f85010af..12b43b37 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -562,6 +562,7 @@ CConfigManager::CConfigManager() {
registerConfigVar("master:allow_small_split", Hyprlang::INT{0});
registerConfigVar("master:smart_resizing", Hyprlang::INT{1});
registerConfigVar("master:drop_at_cursor", Hyprlang::INT{1});
+ registerConfigVar("master:always_keep_position", Hyprlang::INT{0});
registerConfigVar("animations:enabled", Hyprlang::INT{1});
registerConfigVar("animations:first_launch_animation", Hyprlang::INT{1});
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<Hyprlang::INT>("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;