summaryrefslogtreecommitdiff
path: root/src/desktop/Workspace.cpp
diff options
context:
space:
mode:
authorzakk4223 <zakk@rsdio.com>2024-04-18 21:44:51 -0400
committerGitHub <noreply@github.com>2024-04-19 02:44:51 +0100
commit4d0a63523751a590a521fd873f770825023069ae (patch)
tree3777908a5f7414895ad7963695423289340587fb /src/desktop/Workspace.cpp
parent82222342f10a7eff0ec9be972153e740d0f95213 (diff)
workspace: Add 'v' flag for workspace selector that counts only visible windows (#5628)
* Add 'v' flag for workspace selector: counts only visible windows * extra commit because I'm dumb * guard
Diffstat (limited to 'src/desktop/Workspace.cpp')
-rw-r--r--src/desktop/Workspace.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp
index 5789e54f..25015c5a 100644
--- a/src/desktop/Workspace.cpp
+++ b/src/desktop/Workspace.cpp
@@ -251,6 +251,7 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
// m - monitor: m[monitor_selector]
// w - windowCount: w[1-4] or w[1], optional flag t or f for tiled or floating and
// flag g to count groups instead of windows, e.g. w[t1-2], w[fg4]
+ // flag v will count only visible windows
const auto NEXTSPACE = selector.find_first_of(' ', i);
std::string prop = selector.substr(i, NEXTSPACE == std::string::npos ? std::string::npos : NEXTSPACE - i);
@@ -355,8 +356,9 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
prop = prop.substr(2, prop.length() - 3);
- int wantsOnlyTiled = -1;
- bool wantsCountGroup = false;
+ int wantsOnlyTiled = -1;
+ bool wantsCountGroup = false;
+ bool wantsCountVisible = false;
int flagCount = 0;
for (auto& flag : prop) {
@@ -369,6 +371,9 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
} else if (flag == 'g' && !wantsCountGroup) {
wantsCountGroup = true;
flagCount++;
+ } else if (flag == 'v' && !wantsCountVisible) {
+ wantsCountVisible = true;
+ flagCount++;
} else {
break;
}
@@ -392,9 +397,11 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
int count;
if (wantsCountGroup)
- count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
+ count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
+ wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
else
- count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
+ count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
+ wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
if (count != from)
return false;
@@ -424,9 +431,11 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
int count;
if (wantsCountGroup)
- count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
+ count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
+ wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
else
- count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
+ count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled),
+ wantsCountVisible ? std::optional<bool>(wantsCountVisible) : std::nullopt);
if (std::clamp(count, from, to) != count)
return false;