aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2023-03-18 16:12:43 +0000
committervaxerski <[email protected]>2023-03-18 16:12:43 +0000
commit00c2ca46973f4bbeca3cf51cc7fc363cb10710d7 (patch)
tree9d46dd0db3347cb34bc561f5bfcf13bd6ce31c3e
parentd544c30551a7e4c4b0a311535cd9c379f121e753 (diff)
downloadHyprland-00c2ca46973f4bbeca3cf51cc7fc363cb10710d7.tar.gz
Hyprland-00c2ca46973f4bbeca3cf51cc7fc363cb10710d7.zip
config: improve ux on workspace and transform
-rw-r--r--src/config/ConfigManager.cpp20
-rw-r--r--src/config/ConfigManager.hpp21
-rw-r--r--src/helpers/Monitor.cpp6
3 files changed, 29 insertions, 18 deletions
diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp
index a157a108..4abe858c 100644
--- a/src/config/ConfigManager.cpp
+++ b/src/config/ConfigManager.cpp
@@ -558,6 +558,12 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
} else if (ARGS[argno] == "bitdepth") {
newrule.enable10bit = ARGS[argno + 1] == "10";
argno++;
+ } else if (ARGS[argno] == "transform") {
+ newrule.transform = (wl_output_transform)std::stoi(ARGS[argno + 1]);
+ argno++;
+ } else if (ARGS[argno] == "workspace") {
+ m_mDefaultWorkspaces[newrule.name] = ARGS[argno + 1];
+ argno++;
} else {
Debug::log(ERR, "Config error: invalid monitor syntax");
parseError = "invalid syntax at \"" + ARGS[argno] + "\"";
@@ -982,12 +988,7 @@ void CConfigManager::handleBlurLS(const std::string& command, const std::string&
void CConfigManager::handleDefaultWorkspace(const std::string& command, const std::string& value) {
const auto ARGS = CVarList(value);
- for (auto& mr : m_dMonitorRules) {
- if (mr.name == ARGS[0]) {
- mr.defaultWorkspace = ARGS[1];
- break;
- }
- }
+ m_mDefaultWorkspaces[ARGS[0]] = ARGS[1];
}
void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) {
@@ -1926,3 +1927,10 @@ void CConfigManager::addPluginConfigVar(HANDLE handle, const std::string& name,
void CConfigManager::removePluginConfig(HANDLE handle) {
std::erase_if(pluginConfigs, [&](const auto& other) { return other.first == handle; });
}
+
+std::string CConfigManager::getDefaultWorkspaceFor(const std::string& name) {
+ const auto IT = std::find_if(m_mDefaultWorkspaces.begin(), m_mDefaultWorkspaces.end(), [&](const auto& other) { return other.first == name; });
+ if (IT == m_mDefaultWorkspaces.end())
+ return "";
+ return IT->second;
+} \ No newline at end of file
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index f09241f8..e5a5749d 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -34,16 +34,15 @@ struct SConfigValue {
};
struct SMonitorRule {
- std::string name = "";
- Vector2D resolution = Vector2D(1280, 720);
- Vector2D offset = Vector2D(0, 0);
- float scale = 1;
- float refreshRate = 60;
- std::string defaultWorkspace = "";
- bool disabled = false;
- wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
- std::string mirrorOf = "";
- bool enable10bit = false;
+ std::string name = "";
+ Vector2D resolution = Vector2D(1280, 720);
+ Vector2D offset = Vector2D(0, 0);
+ float scale = 1;
+ float refreshRate = 60;
+ bool disabled = false;
+ wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
+ std::string mirrorOf = "";
+ bool enable10bit = false;
};
struct SMonitorAdditionalReservedArea {
@@ -150,6 +149,7 @@ class CConfigManager {
SConfigValue* getConfigValuePtrSafe(const std::string&);
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
+ std::string getDefaultWorkspaceFor(const std::string&);
CMonitor* getBoundMonitorForWS(const std::string&);
std::string getBoundMonitorStringForWS(const std::string&);
@@ -208,6 +208,7 @@ class CConfigManager {
bool isFirstLaunch = true; // For exec-once
std::deque<SMonitorRule> m_dMonitorRules;
+ std::unordered_map<std::string, std::string> m_mDefaultWorkspaces;
std::deque<SWindowRule> m_dWindowRules;
std::deque<SLayerRule> m_dLayerRules;
std::deque<std::string> m_dBlurLSNamespaces;
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index f97c386d..6ad60dfa 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -297,13 +297,15 @@ int CMonitor::findAvailableDefaultWS() {
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
// Workspace
std::string newDefaultWorkspaceName = "";
- int64_t WORKSPACEID = monitorRule.defaultWorkspace == "" ? findAvailableDefaultWS() : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
+ int64_t WORKSPACEID = g_pConfigManager->getDefaultWorkspaceFor(szName).empty() ?
+ findAvailableDefaultWS() :
+ getWorkspaceIDFromString(g_pConfigManager->getDefaultWorkspaceFor(szName), newDefaultWorkspaceName);
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
- Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace.c_str());
+ Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", g_pConfigManager->getDefaultWorkspaceFor(szName).c_str());
}
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);