diff options
| author | memchr <118117622+memchr@users.noreply.github.com> | 2023-09-21 23:42:00 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-22 00:42:00 +0100 |
| commit | 1357b66091ecd73f097d19d527a23a9ae72a4ff1 (patch) | |
| tree | e629bedcce584757ebd1afae0dcc12ea25f15c95 /src/events/Windows.cpp | |
| parent | 2e1842b5ff140bc81a604c663482221d86c30cff (diff) | |
windowrules: add rule `group` to map windows grouped (#3279)
* windows: add rule group to map windows grouped
* group rule: use `invade` to force open a window in a locked group
Diffstat (limited to 'src/events/Windows.cpp')
| -rw-r--r-- | src/events/Windows.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 41c19ab4..d0ae4ae8 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -198,6 +198,53 @@ void Events::listener_mapWindow(void* owner, void* data) { overridingNoMaximize = true; } else if (r.szRule == "stayfocused") { PWINDOW->m_bStayFocused = true; + } else if (r.szRule.find("group") == 0) { + if (PWINDOW->m_eGroupRules & GROUP_OVERRIDE) + continue; + + // `group` is a shorthand of `group set` + if (removeBeginEndSpacesTabs(r.szRule) == "group") { + PWINDOW->m_eGroupRules |= GROUP_SET; + continue; + } + + CVarList vars(r.szRule, 0, 's'); + std::string vPrev = ""; + + for (auto const& v : vars) { + if (v == "group") + continue; + + if (v == "set") { + PWINDOW->m_eGroupRules |= GROUP_SET; + } else if (v == "new") { + // shorthand for `group barred set` + PWINDOW->m_eGroupRules |= (GROUP_SET | GROUP_BARRED); + } else if (v == "lock") { + PWINDOW->m_eGroupRules |= GROUP_LOCK; + } else if (v == "invade") { + PWINDOW->m_eGroupRules |= GROUP_INVADE; + } else if (v == "barred") { + PWINDOW->m_eGroupRules |= GROUP_BARRED; + } else if (v == "deny") { + PWINDOW->m_sGroupData.deny = true; + } else if (v == "override") { + // Clear existing rules + PWINDOW->m_eGroupRules = GROUP_OVERRIDE; + } else if (v == "unset") { + // Clear existing rules and stop processing + PWINDOW->m_eGroupRules = GROUP_OVERRIDE; + break; + } else if (v == "always") { + if (vPrev == "set" || vPrev == "group") + PWINDOW->m_eGroupRules |= GROUP_SET_ALWAYS; + else if (vPrev == "lock") + PWINDOW->m_eGroupRules |= GROUP_LOCK_ALWAYS; + else + Debug::log(ERR, "windowrule `group` does not support `{} always`", vPrev); + } + vPrev = v; + } } else if (r.szRule.find("idleinhibit") == 0) { auto IDLERULE = r.szRule.substr(r.szRule.find_first_of(' ') + 1); |
