diff options
| author | shezdy <77217897+shezdy@users.noreply.github.com> | 2026-04-30 13:10:03 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-30 20:10:03 +0100 |
| commit | 546cc71565cd2ccd9277febb14dcebf513ace623 (patch) | |
| tree | fe0cbe8e7e415f77158965cd11925572efc30fb7 /src | |
| parent | bac49db9a11d5398963f4ad3265a577f8e94dc66 (diff) | |
config/workspace-rules: support modifying persistent and monitor (#14217)
* workspace rules: support modifying persistent and monitor
* support modifying isDefault
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compositor.cpp | 4 | ||||
| -rw-r--r-- | src/config/shared/workspace/WorkspaceRule.cpp | 10 | ||||
| -rw-r--r-- | src/config/shared/workspace/WorkspaceRule.hpp | 4 | ||||
| -rw-r--r-- | src/config/shared/workspace/WorkspaceRuleManager.cpp | 2 | ||||
| -rw-r--r-- | src/debug/HyprCtl.cpp | 8 | ||||
| -rw-r--r-- | src/desktop/Workspace.cpp | 6 |
6 files changed, 17 insertions, 17 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 14a7843e..c6430027 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1699,7 +1699,7 @@ WORKSPACEID CCompositor::getNextAvailableNamedWorkspace() { // Give priority to persistent workspaces to avoid any conflicts between them. for (auto const& rule : Config::workspaceRuleMgr()->getAllWorkspaceRules()) { - if (!rule.m_isPersistent) + if (!rule.m_isPersistent.value_or(false)) continue; if (rule.m_workspaceId < -1 && rule.m_workspaceId < lowest) lowest = rule.m_workspaceId; @@ -3096,7 +3096,7 @@ void CCompositor::ensurePersistentWorkspacesPresent(const std::vector<Config::CW std::vector<PHLWORKSPACE> persistentFound; for (const auto& rule : rules) { - if (!rule.m_isPersistent) + if (!rule.m_isPersistent.value_or(false)) continue; PHLWORKSPACE PWORKSPACE = nullptr; diff --git a/src/config/shared/workspace/WorkspaceRule.cpp b/src/config/shared/workspace/WorkspaceRule.cpp index 28d5fcab..dfd77d42 100644 --- a/src/config/shared/workspace/WorkspaceRule.cpp +++ b/src/config/shared/workspace/WorkspaceRule.cpp @@ -3,7 +3,7 @@ using namespace Config; void CWorkspaceRule::mergeLeft(const CWorkspaceRule& other) { - if (m_monitor.empty()) + if (!other.m_monitor.empty()) m_monitor = other.m_monitor; if (m_workspaceString.empty()) m_workspaceString = other.m_workspaceString; @@ -12,10 +12,10 @@ void CWorkspaceRule::mergeLeft(const CWorkspaceRule& other) { if (m_workspaceId == WORKSPACE_INVALID) m_workspaceId = other.m_workspaceId; - if (other.m_isDefault) - m_isDefault = true; - if (other.m_isPersistent) - m_isPersistent = true; + if (other.m_isDefault.has_value()) + m_isDefault = other.m_isDefault; + if (other.m_isPersistent.has_value()) + m_isPersistent = other.m_isPersistent; if (other.m_gapsIn.has_value()) m_gapsIn = other.m_gapsIn; if (other.m_gapsOut.has_value()) diff --git a/src/config/shared/workspace/WorkspaceRule.hpp b/src/config/shared/workspace/WorkspaceRule.hpp index 5d63e434..e56a1366 100644 --- a/src/config/shared/workspace/WorkspaceRule.hpp +++ b/src/config/shared/workspace/WorkspaceRule.hpp @@ -27,8 +27,8 @@ namespace Config { std::string m_workspaceString = ""; std::string m_workspaceName = ""; WORKSPACEID m_workspaceId = -1; - bool m_isDefault = false; - bool m_isPersistent = false; + std::optional<bool> m_isDefault; + std::optional<bool> m_isPersistent; std::optional<CCssGapData> m_gapsIn; std::optional<CCssGapData> m_gapsOut; std::optional<CCssGapData> m_floatGaps = m_gapsOut; diff --git a/src/config/shared/workspace/WorkspaceRuleManager.cpp b/src/config/shared/workspace/WorkspaceRuleManager.cpp index 4c2c2b90..04b94a53 100644 --- a/src/config/shared/workspace/WorkspaceRuleManager.cpp +++ b/src/config/shared/workspace/WorkspaceRuleManager.cpp @@ -55,7 +55,7 @@ std::string CWorkspaceRuleManager::getDefaultWorkspaceFor(const std::string& nam if (!other->m_enabled) continue; - if (other->m_isDefault) { + if (other->m_isDefault.value_or(false)) { if (other->m_monitor == name) return other->m_workspaceString; if (other->m_monitor.starts_with("desc:")) { diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index b334a26e..11171472 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -507,8 +507,8 @@ static std::string getWorkspaceRuleData(const Config::CWorkspaceRule& r, eHyprCt const auto boolToString = [](const bool b) -> std::string { return b ? "true" : "false"; }; if (format == eHyprCtlOutputFormat::FORMAT_JSON) { const std::string monitor = r.m_monitor.empty() ? "" : std::format(",\n \"monitor\": \"{}\"", escapeJSONStrings(r.m_monitor)); - const std::string default_ = sc<bool>(r.m_isDefault) ? std::format(",\n \"default\": {}", boolToString(r.m_isDefault)) : ""; - const std::string persistent = sc<bool>(r.m_isPersistent) ? std::format(",\n \"persistent\": {}", boolToString(r.m_isPersistent)) : ""; + const std::string default_ = sc<bool>(r.m_isDefault) ? std::format(",\n \"default\": {}", boolToString(r.m_isDefault.value())) : ""; + const std::string persistent = sc<bool>(r.m_isPersistent) ? std::format(",\n \"persistent\": {}", boolToString(r.m_isPersistent.value())) : ""; const std::string gapsIn = sc<bool>(r.m_gapsIn) ? std::format(",\n \"gapsIn\": [{}, {}, {}, {}]", r.m_gapsIn.value().m_top, r.m_gapsIn.value().m_right, r.m_gapsIn.value().m_bottom, r.m_gapsIn.value().m_left) : ""; @@ -531,8 +531,8 @@ static std::string getWorkspaceRuleData(const Config::CWorkspaceRule& r, eHyprCt return result; } else { const std::string monitor = std::format("\tmonitor: {}\n", r.m_monitor.empty() ? "<unset>" : escapeJSONStrings(r.m_monitor)); - const std::string default_ = std::format("\tdefault: {}\n", sc<bool>(r.m_isDefault) ? boolToString(r.m_isDefault) : "<unset>"); - const std::string persistent = std::format("\tpersistent: {}\n", sc<bool>(r.m_isPersistent) ? boolToString(r.m_isPersistent) : "<unset>"); + const std::string default_ = std::format("\tdefault: {}\n", sc<bool>(r.m_isDefault) ? boolToString(r.m_isDefault.value()) : "<unset>"); + const std::string persistent = std::format("\tpersistent: {}\n", sc<bool>(r.m_isPersistent) ? boolToString(r.m_isPersistent.value()) : "<unset>"); const std::string gapsIn = sc<bool>(r.m_gapsIn) ? std::format("\tgapsIn: {} {} {} {}\n", std::to_string(r.m_gapsIn.value().m_top), std::to_string(r.m_gapsIn.value().m_right), std::to_string(r.m_gapsIn.value().m_bottom), std::to_string(r.m_gapsIn.value().m_left)) : diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index 6d8e6cb4..60d8d985 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -52,7 +52,7 @@ void CWorkspace::init(PHLWORKSPACE self) { m_inert = false; const auto WORKSPACERULE = Config::workspaceRuleMgr()->getWorkspaceRuleFor(self).value_or(Config::CWorkspaceRule{}); - setPersistent(WORKSPACERULE.m_isPersistent); + setPersistent(WORKSPACERULE.m_isPersistent.value_or(false)); if (self->m_wasCreatedEmpty) if (auto cmd = WORKSPACERULE.m_onCreatedEmptyRunCmd) @@ -517,9 +517,9 @@ void CWorkspace::rename(const std::string& name) { m_name = name; const auto WORKSPACERULE = Config::workspaceRuleMgr()->getWorkspaceRuleFor(m_self.lock()).value_or(Config::CWorkspaceRule{}); - setPersistent(WORKSPACERULE.m_isPersistent); + setPersistent(WORKSPACERULE.m_isPersistent.value_or(false)); - if (WORKSPACERULE.m_isPersistent) + if (WORKSPACERULE.m_isPersistent.value_or(false)) g_pCompositor->ensurePersistentWorkspacesPresent(std::vector<Config::CWorkspaceRule>{WORKSPACERULE}, m_self.lock()); g_pEventManager->postEvent({.event = "renameworkspace", .data = std::to_string(m_id) + "," + m_name}); |
