aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorthejch <[email protected]>2024-03-31 19:02:47 -0700
committerGitHub <[email protected]>2024-04-01 03:02:47 +0100
commitef7ac53e99c9c443241fd50a38e6edf528df3d7b (patch)
tree01dc2a570a7169665de0ca1e9d78347ef81e688d
parent9ae0c47a21476d064ab93b6fb87cedbf20096b8e (diff)
downloadHyprland-ef7ac53e99c9c443241fd50a38e6edf528df3d7b.tar.gz
Hyprland-ef7ac53e99c9c443241fd50a38e6edf528df3d7b.zip
master: Make master workspace orientation rule dynamic (#5339)
* make master workspace orientation rule dynamic * fix rebase * fix special ws resizing * style
-rw-r--r--src/layout/MasterLayout.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index 9c49197e..cac64c6d 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -53,17 +53,16 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
orientationForWs = wsRule.layoutopts.at("orientation");
}
- if (orientationForWs == "top") {
+ if (orientationForWs == "top")
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
- } else if (orientationForWs == "right") {
+ else if (orientationForWs == "right")
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
- } else if (orientationForWs == "bottom") {
+ else if (orientationForWs == "bottom")
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
- } else if (orientationForWs == "center") {
+ else if (orientationForWs == "center")
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
- } else {
+ else
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
- }
return PWORKSPACEDATA;
}
@@ -339,6 +338,26 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
if (!PMASTERNODE)
return;
+ // dynamic workspace rules
+ const auto WORKSPACERULES = g_pConfigManager->getWorkspaceRulesFor(g_pCompositor->getWorkspaceByID(ws));
+ std::string orientationForWs;
+
+ for (auto& wsRule : WORKSPACERULES) {
+ if (wsRule.layoutopts.contains("orientation"))
+ orientationForWs = wsRule.layoutopts.at("orientation");
+ }
+
+ if (orientationForWs == "top")
+ PWORKSPACEDATA->orientation = ORIENTATION_TOP;
+ else if (orientationForWs == "right")
+ PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
+ else if (orientationForWs == "bottom")
+ PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
+ else if (orientationForWs == "center")
+ PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
+ else if (orientationForWs == "left")
+ PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
+
eOrientation orientation = PWORKSPACEDATA->orientation;
bool centerMasterWindow = false;
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
@@ -753,7 +772,7 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, eRectCorne
}
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
- const auto PWORKSPACEDATA = getMasterWorkspaceData(PMONITOR->activeWorkspace);
+ const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->m_iWorkspaceID);
static auto ALWAYSCENTER = CConfigValue<Hyprlang::INT>("master:always_center_master");
static auto PSMARTRESIZING = CConfigValue<Hyprlang::INT>("master:smart_resizing");