mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-02 01:05:59 +01:00
config: improve layoutopt handling for workspacerules
This commit is contained in:
parent
e53134ca90
commit
ea7569d7e0
3 changed files with 35 additions and 24 deletions
|
@ -1227,8 +1227,20 @@ 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)
|
else if ((delim = rule.find("layoutopt:")) != std::string::npos) {
|
||||||
wsRule.layoutopts["orientation"] = rule.substr(delim + 22);
|
std::string opt = rule.substr(delim + 10);
|
||||||
|
if (!opt.contains(":")) {
|
||||||
|
// invalid
|
||||||
|
Debug::log(ERR, "Invalid workspace rule found: {}", rule);
|
||||||
|
parseError = "Invalid workspace rule found: " + rule;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string val = opt.substr(opt.find(":") + 1);
|
||||||
|
opt = opt.substr(0, opt.find(":"));
|
||||||
|
|
||||||
|
wsRule.layoutopts[opt] = val;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
|
@ -37,21 +37,21 @@ struct SConfigValue {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SWorkspaceRule {
|
struct SWorkspaceRule {
|
||||||
std::string monitor = "";
|
std::string monitor = "";
|
||||||
std::string workspaceString = "";
|
std::string workspaceString = "";
|
||||||
std::string workspaceName = "";
|
std::string workspaceName = "";
|
||||||
int workspaceId = -1;
|
int workspaceId = -1;
|
||||||
bool isDefault = false;
|
bool isDefault = false;
|
||||||
bool isPersistent = false;
|
bool isPersistent = false;
|
||||||
std::optional<int64_t> gapsIn;
|
std::optional<int64_t> gapsIn;
|
||||||
std::optional<int64_t> gapsOut;
|
std::optional<int64_t> gapsOut;
|
||||||
std::optional<int64_t> borderSize;
|
std::optional<int64_t> borderSize;
|
||||||
std::optional<int> border;
|
std::optional<int> border;
|
||||||
std::optional<int> rounding;
|
std::optional<int> rounding;
|
||||||
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;
|
std::map<std::string, std::string> layoutopts;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorAdditionalReservedArea {
|
struct SMonitorAdditionalReservedArea {
|
||||||
|
|
|
@ -45,10 +45,8 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
|
||||||
const auto layoutoptsForWs = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(ws)).layoutopts;
|
const auto layoutoptsForWs = g_pConfigManager->getWorkspaceRuleFor(g_pCompositor->getWorkspaceByID(ws)).layoutopts;
|
||||||
auto orientationForWs = *orientation;
|
auto orientationForWs = *orientation;
|
||||||
|
|
||||||
try {
|
if (layoutoptsForWs.contains("orientation"))
|
||||||
if (layoutoptsForWs.contains("orientation"))
|
orientationForWs = layoutoptsForWs.at("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") {
|
if (orientationForWs == "top") {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||||
|
@ -56,11 +54,12 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
||||||
} else if (orientationForWs == "bottom") {
|
} else if (orientationForWs == "bottom") {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
||||||
} else if (orientationForWs == "left") {
|
} else if (orientationForWs == "center") {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
|
||||||
} else {
|
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
|
PWORKSPACEDATA->orientation = ORIENTATION_CENTER;
|
||||||
|
} else {
|
||||||
|
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PWORKSPACEDATA;
|
return PWORKSPACEDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue