mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-23 06:25:58 +01:00
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
This commit is contained in:
parent
6e8b9ef7d8
commit
758cf90ea1
3 changed files with 29 additions and 18 deletions
|
@ -1214,6 +1214,8 @@ void CConfigManager::handleWorkspaceRules(const std::string& command, const std:
|
||||||
wsRule.isPersistent = configStringToInt(rule.substr(delim + 11));
|
wsRule.isPersistent = configStringToInt(rule.substr(delim + 11));
|
||||||
else if ((delim = rule.find(ruleOnCreatedEmtpy)) != std::string::npos)
|
else if ((delim = rule.find(ruleOnCreatedEmtpy)) != std::string::npos)
|
||||||
wsRule.onCreatedEmptyRunCmd = cleanCmdForWorkspace(name, rule.substr(delim + ruleOnCreatedEmtpyLen));
|
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;
|
size_t pos = 0;
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct SWorkspaceRule {
|
||||||
std::optional<int> decorate;
|
std::optional<int> decorate;
|
||||||
std::optional<int> shadow;
|
std::optional<int> shadow;
|
||||||
std::optional<std::string> onCreatedEmptyRunCmd;
|
std::optional<std::string> onCreatedEmptyRunCmd;
|
||||||
|
std::map<std::string, std::any> layoutopts;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorAdditionalReservedArea {
|
struct SMonitorAdditionalReservedArea {
|
||||||
|
|
|
@ -42,13 +42,21 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
|
||||||
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
||||||
PWORKSPACEDATA->workspaceID = ws;
|
PWORKSPACEDATA->workspaceID = ws;
|
||||||
const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
|
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;
|
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||||
} else if (*orientation == "right") {
|
} else if (orientationForWs == "right") {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
||||||
} else if (*orientation == "bottom") {
|
} else if (orientationForWs == "bottom") {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
||||||
} else if (*orientation == "left") {
|
} else if (orientationForWs == "left") {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
||||||
} else {
|
} else {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
|
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
|
||||||
|
|
Loading…
Reference in a new issue