mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-26 10:09:48 +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") {
|
||||
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;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue