aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorthejch <[email protected]>2023-12-02 06:42:49 -0800
committerGitHub <[email protected]>2023-12-02 14:42:49 +0000
commit758cf90ea1066eea361a9d8c347e7fcf40f6636f (patch)
treea7455a55a5d8eead8f42bee08fe0b54a1e3ee535
parent6e8b9ef7d8aa53247d5122b6641b9afa0df798df (diff)
downloadHyprland-758cf90ea1066eea361a9d8c347e7fcf40f6636f.tar.gz
Hyprland-758cf90ea1066eea361a9d8c347e7fcf40f6636f.zip
workspacerules: Add workspace rule for master layout orientation (#3964)
* add workspace rule for master layout orientation * change rule format * edit rule name * use map for layoutopts * use std::any instead of string
-rw-r--r--src/config/ConfigManager.cpp2
-rw-r--r--src/config/ConfigManager.hpp29
-rw-r--r--src/layout/MasterLayout.cpp16
3 files changed, 29 insertions, 18 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index 257446ee..5659667e 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -1214,6 +1214,8 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
wsRule.isPersistent = configStringToInt(rule.substr(delim + 11));
else if ((delim = rule.find(ruleOnCreatedEmtpy)) != std::string::npos)
wsRule.onCreatedEmptyRunCmd = cleanCmdForWorkspace(name, rule.substr(delim + ruleOnCreatedEmtpyLen));
+ else if ((delim = rule.find("layoutopt:orientation:")) != std::string::npos)
+ wsRule.layoutopts["orientation"] = rule.substr(delim + 22);
};
size_t pos = 0;
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index f89ae72c..8009100e 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -37,20 +37,21 @@ struct SConfigValue {
};
struct SWorkspaceRule {
- std::string monitor = "";
- std::string workspaceString = "";
- std::string workspaceName = "";
- int workspaceId = -1;
- bool isDefault = false;
- bool isPersistent = false;
- std::optional<int64_t> gapsIn;
- std::optional<int64_t> gapsOut;
- std::optional<int64_t> borderSize;
- std::optional<int> border;
- std::optional<int> rounding;
- std::optional<int> decorate;
- std::optional<int> shadow;
- std::optional<std::string> onCreatedEmptyRunCmd;
+ std::string monitor = "";
+ std::string workspaceString = "";
+ std::string workspaceName = "";
+ int workspaceId = -1;
+ bool isDefault = false;
+ bool isPersistent = false;
+ std::optional<int64_t> gapsIn;
+ std::optional<int64_t> gapsOut;
+ std::optional<int64_t> borderSize;
+ std::optional<int> border;
+ std::optional<int> rounding;
+ std::optional<int> decorate;
+ std::optional<int> shadow;
+ std::optional<std::string> onCreatedEmptyRunCmd;
+ std::map<std::string, std::any> layoutopts;
};
struct SMonitorAdditionalReservedArea {
diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp
index d355a7d3..3977d8f6 100644
--- a/src/layout/MasterLayout.cpp
+++ b/src/layout/MasterLayout.cpp
@@ -42,13 +42,21 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
PWORKSPACEDATA->workspaceID = ws;
const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
- if (*orientation == "top") {
+ const auto layoutoptsForWs = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(ws)).layoutopts;
+ auto orientationForWs = *orientation;
+
+ try {
+ if (layoutoptsForWs.contains("orientation"))
+ orientationForWs = std::any_cast<std::string>(layoutoptsForWs.at("orientation"));
+ } catch (std::exception& e) { Debug::log(ERR, "Error from layoutopt rules: {}", e.what()); }
+
+ if (orientationForWs == "top") {
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
- } else if (*orientation == "right") {
+ } else if (orientationForWs == "right") {
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
- } else if (*orientation == "bottom") {
+ } else if (orientationForWs == "bottom") {
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
- } else if (*orientation == "left") {
+ } else if (orientationForWs == "left") {
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
} else {
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;