summaryrefslogtreecommitdiff
path: root/src/layout/algorithm/tiled
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-02-25 23:54:13 +0000
committerGitHub <noreply@github.com>2026-02-25 23:54:13 +0000
commit1e06ab464ff1aa1e8d3f79b4aa702cab101edfb0 (patch)
tree86a86845cb7e953f90ac4bc68bcee88e1ab3e63c /src/layout/algorithm/tiled
parent623185170b89c12205e9e093576b9c71118d3f59 (diff)
algo/master: fix orientation cycling (#13372)
Diffstat (limited to 'src/layout/algorithm/tiled')
-rw-r--r--src/layout/algorithm/tiled/master/MasterAlgorithm.cpp68
-rw-r--r--src/layout/algorithm/tiled/master/MasterAlgorithm.hpp5
2 files changed, 39 insertions, 34 deletions
diff --git a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp
index a0329b22..7f421e49 100644
--- a/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp
+++ b/src/layout/algorithm/tiled/master/MasterAlgorithm.cpp
@@ -668,15 +668,15 @@ std::expected<void, std::string> CMasterAlgorithm::layoutMsg(const std::string_v
g_pCompositor->setWindowFullscreenInternal(PWINDOW, FSMODE_NONE);
if (command == "orientationleft")
- m_workspaceData.orientation = ORIENTATION_LEFT;
+ m_workspaceData.explicitOrientation = ORIENTATION_LEFT;
else if (command == "orientationright")
- m_workspaceData.orientation = ORIENTATION_RIGHT;
+ m_workspaceData.explicitOrientation = ORIENTATION_RIGHT;
else if (command == "orientationtop")
- m_workspaceData.orientation = ORIENTATION_TOP;
+ m_workspaceData.explicitOrientation = ORIENTATION_TOP;
else if (command == "orientationbottom")
- m_workspaceData.orientation = ORIENTATION_BOTTOM;
+ m_workspaceData.explicitOrientation = ORIENTATION_BOTTOM;
else if (command == "orientationcenter")
- m_workspaceData.orientation = ORIENTATION_CENTER;
+ m_workspaceData.explicitOrientation = ORIENTATION_CENTER;
calculateWorkspace();
} else if (command == "orientationnext") {
@@ -837,6 +837,34 @@ void CMasterAlgorithm::buildOrientationCycleVectorFromEOperation(std::vector<eOr
}
}
+eOrientation CMasterAlgorithm::defaultOrientation() {
+ static auto PORIENT = CConfigValue<std::string>("master:orientation");
+
+ const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_parent->space()->workspace());
+ std::string orientationString;
+ if (WORKSPACERULE.layoutopts.contains("orientation"))
+ orientationString = WORKSPACERULE.layoutopts.at("orientation");
+ else
+ orientationString = *PORIENT;
+
+ eOrientation orientation = ORIENTATION_LEFT;
+ // override if workspace rule is set
+ if (!orientationString.empty()) {
+ if (orientationString == "top")
+ orientation = ORIENTATION_TOP;
+ else if (orientationString == "right")
+ orientation = ORIENTATION_RIGHT;
+ else if (orientationString == "bottom")
+ orientation = ORIENTATION_BOTTOM;
+ else if (orientationString == "center")
+ orientation = ORIENTATION_CENTER;
+ else
+ orientation = ORIENTATION_LEFT;
+ }
+
+ return orientation;
+}
+
void CMasterAlgorithm::runOrientationCycle(Hyprutils::String::CVarList2* vars, int next) {
std::vector<eOrientation> cycle;
if (vars != nullptr)
@@ -854,7 +882,7 @@ void CMasterAlgorithm::runOrientationCycle(Hyprutils::String::CVarList2* vars, i
int nextOrPrev = 0;
for (size_t i = 0; i < cycle.size(); ++i) {
- if (m_workspaceData.orientation == cycle[i]) {
+ if (m_workspaceData.explicitOrientation.value_or(defaultOrientation()) == cycle[i]) {
nextOrPrev = i + next;
break;
}
@@ -865,36 +893,12 @@ void CMasterAlgorithm::runOrientationCycle(Hyprutils::String::CVarList2* vars, i
else if (nextOrPrev < 0)
nextOrPrev = cycle.size() + (nextOrPrev % sc<int>(cycle.size()));
- m_workspaceData.orientation = cycle.at(nextOrPrev);
+ m_workspaceData.explicitOrientation = cycle.at(nextOrPrev);
calculateWorkspace();
}
eOrientation CMasterAlgorithm::getDynamicOrientation() {
- static auto PORIENT = CConfigValue<std::string>("master:orientation");
-
- const auto WORKSPACERULE = g_pConfigManager->getWorkspaceRuleFor(m_parent->space()->workspace());
- std::string orientationString;
- if (WORKSPACERULE.layoutopts.contains("orientation"))
- orientationString = WORKSPACERULE.layoutopts.at("orientation");
- else
- orientationString = *PORIENT;
-
- eOrientation orientation = m_workspaceData.orientation;
- // override if workspace rule is set
- if (!orientationString.empty()) {
- if (orientationString == "top")
- orientation = ORIENTATION_TOP;
- else if (orientationString == "right")
- orientation = ORIENTATION_RIGHT;
- else if (orientationString == "bottom")
- orientation = ORIENTATION_BOTTOM;
- else if (orientationString == "center")
- orientation = ORIENTATION_CENTER;
- else
- orientation = ORIENTATION_LEFT;
- }
-
- return orientation;
+ return m_workspaceData.explicitOrientation.value_or(defaultOrientation());
}
int CMasterAlgorithm::getNodesNo() {
diff --git a/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp b/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp
index 4524587f..5cfa6b36 100644
--- a/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp
+++ b/src/layout/algorithm/tiled/master/MasterAlgorithm.hpp
@@ -19,8 +19,8 @@ namespace Layout::Tiled {
};
struct SMasterWorkspaceData {
- WORKSPACEID workspaceID = WORKSPACE_INVALID;
- eOrientation orientation = ORIENTATION_LEFT;
+ WORKSPACEID workspaceID = WORKSPACE_INVALID;
+ std::optional<eOrientation> explicitOrientation;
// Previously focused non-master window when `focusmaster previous` command was issued
WP<ITarget> focusMasterPrev;
@@ -71,5 +71,6 @@ namespace Layout::Tiled {
SP<ITarget> getNextTarget(SP<ITarget>, bool, bool);
int getMastersNo();
bool isWindowTiled(PHLWINDOW);
+ eOrientation defaultOrientation();
};
}; \ No newline at end of file