mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 23:05:58 +01:00
config: improve ux on workspace and transform
This commit is contained in:
parent
d544c30551
commit
00c2ca4697
3 changed files with 29 additions and 18 deletions
|
@ -558,6 +558,12 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
} else if (ARGS[argno] == "bitdepth") {
|
} else if (ARGS[argno] == "bitdepth") {
|
||||||
newrule.enable10bit = ARGS[argno + 1] == "10";
|
newrule.enable10bit = ARGS[argno + 1] == "10";
|
||||||
argno++;
|
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 {
|
} else {
|
||||||
Debug::log(ERR, "Config error: invalid monitor syntax");
|
Debug::log(ERR, "Config error: invalid monitor syntax");
|
||||||
parseError = "invalid syntax at \"" + ARGS[argno] + "\"";
|
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) {
|
void CConfigManager::handleDefaultWorkspace(const std::string& command, const std::string& value) {
|
||||||
const auto ARGS = CVarList(value);
|
const auto ARGS = CVarList(value);
|
||||||
|
|
||||||
for (auto& mr : m_dMonitorRules) {
|
m_mDefaultWorkspaces[ARGS[0]] = ARGS[1];
|
||||||
if (mr.name == ARGS[0]) {
|
|
||||||
mr.defaultWorkspace = ARGS[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::handleSubmap(const std::string& command, const std::string& submap) {
|
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) {
|
void CConfigManager::removePluginConfig(HANDLE handle) {
|
||||||
std::erase_if(pluginConfigs, [&](const auto& other) { return other.first == 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;
|
||||||
|
}
|
|
@ -34,16 +34,15 @@ struct SConfigValue {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorRule {
|
struct SMonitorRule {
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
Vector2D resolution = Vector2D(1280, 720);
|
Vector2D resolution = Vector2D(1280, 720);
|
||||||
Vector2D offset = Vector2D(0, 0);
|
Vector2D offset = Vector2D(0, 0);
|
||||||
float scale = 1;
|
float scale = 1;
|
||||||
float refreshRate = 60;
|
float refreshRate = 60;
|
||||||
std::string defaultWorkspace = "";
|
bool disabled = false;
|
||||||
bool disabled = false;
|
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
std::string mirrorOf = "";
|
||||||
std::string mirrorOf = "";
|
bool enable10bit = false;
|
||||||
bool enable10bit = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorAdditionalReservedArea {
|
struct SMonitorAdditionalReservedArea {
|
||||||
|
@ -150,6 +149,7 @@ class CConfigManager {
|
||||||
SConfigValue* getConfigValuePtrSafe(const std::string&);
|
SConfigValue* getConfigValuePtrSafe(const std::string&);
|
||||||
|
|
||||||
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
|
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
|
||||||
|
std::string getDefaultWorkspaceFor(const std::string&);
|
||||||
|
|
||||||
CMonitor* getBoundMonitorForWS(const std::string&);
|
CMonitor* getBoundMonitorForWS(const std::string&);
|
||||||
std::string getBoundMonitorStringForWS(const std::string&);
|
std::string getBoundMonitorStringForWS(const std::string&);
|
||||||
|
@ -208,6 +208,7 @@ class CConfigManager {
|
||||||
bool isFirstLaunch = true; // For exec-once
|
bool isFirstLaunch = true; // For exec-once
|
||||||
|
|
||||||
std::deque<SMonitorRule> m_dMonitorRules;
|
std::deque<SMonitorRule> m_dMonitorRules;
|
||||||
|
std::unordered_map<std::string, std::string> m_mDefaultWorkspaces;
|
||||||
std::deque<SWindowRule> m_dWindowRules;
|
std::deque<SWindowRule> m_dWindowRules;
|
||||||
std::deque<SLayerRule> m_dLayerRules;
|
std::deque<SLayerRule> m_dLayerRules;
|
||||||
std::deque<std::string> m_dBlurLSNamespaces;
|
std::deque<std::string> m_dBlurLSNamespaces;
|
||||||
|
|
|
@ -297,13 +297,15 @@ int CMonitor::findAvailableDefaultWS() {
|
||||||
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
|
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
|
||||||
// Workspace
|
// Workspace
|
||||||
std::string newDefaultWorkspaceName = "";
|
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)) {
|
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
|
||||||
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
||||||
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
|
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);
|
auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(WORKSPACEID);
|
||||||
|
|
Loading…
Reference in a new issue