mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-09-11 13:25:42 +03:00
workspace: Add count group flag in windowCount workspace selector prop (#5499)
* Add groupCount workspace selector prop * Intergrate groupCount with windowCount
This commit is contained in:
parent
f6786f04d2
commit
fcac25bcc2
@ -1280,6 +1280,16 @@ int CCompositor::getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTi
|
|||||||
return no;
|
return no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CCompositor::getGroupsOnWorkspace(const int& id, std::optional<bool> onlyTiled) {
|
||||||
|
int no = 0;
|
||||||
|
for (auto& w : m_vWindows) {
|
||||||
|
if (w->workspaceID() == id && w->m_bIsMapped && !(onlyTiled.has_value() && !w->m_bIsFloating != onlyTiled.value()) && w->m_sGroupData.head)
|
||||||
|
no++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return no;
|
||||||
|
}
|
||||||
|
|
||||||
CWindow* CCompositor::getUrgentWindow() {
|
CWindow* CCompositor::getUrgentWindow() {
|
||||||
for (auto& w : m_vWindows) {
|
for (auto& w : m_vWindows) {
|
||||||
if (w->m_bIsMapped && w->m_bIsUrgent)
|
if (w->m_bIsMapped && w->m_bIsUrgent)
|
||||||
|
@ -151,6 +151,7 @@ class CCompositor {
|
|||||||
void sanityCheckWorkspaces();
|
void sanityCheckWorkspaces();
|
||||||
void updateWorkspaceWindowDecos(const int&);
|
void updateWorkspaceWindowDecos(const int&);
|
||||||
int getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {});
|
int getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {});
|
||||||
|
int getGroupsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {});
|
||||||
CWindow* getUrgentWindow();
|
CWindow* getUrgentWindow();
|
||||||
bool hasUrgentWindowOnWorkspace(const int&);
|
bool hasUrgentWindowOnWorkspace(const int&);
|
||||||
CWindow* getFirstWindowOnWorkspace(const int&);
|
CWindow* getFirstWindowOnWorkspace(const int&);
|
||||||
|
@ -852,6 +852,7 @@ void CWindow::destroyGroup() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_sGroupData.pNextWindow = nullptr;
|
m_sGroupData.pNextWindow = nullptr;
|
||||||
|
m_sGroupData.head = false;
|
||||||
updateWindowDecos();
|
updateWindowDecos();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,8 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
// s - special: s[true]
|
// s - special: s[true]
|
||||||
// n - named: n[true] or n[s:string] or n[e:string]
|
// n - named: n[true] or n[s:string] or n[e:string]
|
||||||
// m - monitor: m[monitor_selector]
|
// m - monitor: m[monitor_selector]
|
||||||
// w - windowCount: w[0-4] or w[1], optional flag t or f for tiled or floating, e.g. w[t0-1]
|
// 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]
|
||||||
|
|
||||||
const auto NEXTSPACE = selector.find_first_of(' ', i);
|
const auto NEXTSPACE = selector.find_first_of(' ', i);
|
||||||
std::string prop = selector.substr(i, NEXTSPACE == std::string::npos ? std::string::npos : NEXTSPACE - i);
|
std::string prop = selector.substr(i, NEXTSPACE == std::string::npos ? std::string::npos : NEXTSPACE - i);
|
||||||
@ -354,15 +355,25 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
|
|
||||||
prop = prop.substr(2, prop.length() - 3);
|
prop = prop.substr(2, prop.length() - 3);
|
||||||
|
|
||||||
int wantsOnlyTiled = -1;
|
int wantsOnlyTiled = -1;
|
||||||
|
bool wantsCountGroup = false;
|
||||||
|
|
||||||
if (prop.starts_with("t")) {
|
int flagCount = 0;
|
||||||
wantsOnlyTiled = 1;
|
for (auto& flag : prop) {
|
||||||
prop = prop.substr(1);
|
if (flag == 't' && wantsOnlyTiled == -1) {
|
||||||
} else if (prop.starts_with("f")) {
|
wantsOnlyTiled = 1;
|
||||||
wantsOnlyTiled = 0;
|
flagCount++;
|
||||||
prop = prop.substr(1);
|
} else if (flag == 'f' && wantsOnlyTiled == -1) {
|
||||||
|
wantsOnlyTiled = 0;
|
||||||
|
flagCount++;
|
||||||
|
} else if (flag == 'g' && !wantsCountGroup) {
|
||||||
|
wantsCountGroup = true;
|
||||||
|
flagCount++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
prop = prop.substr(flagCount);
|
||||||
|
|
||||||
if (!prop.contains("-")) {
|
if (!prop.contains("-")) {
|
||||||
// try single
|
// try single
|
||||||
@ -379,7 +390,15 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled)) == from;
|
int count;
|
||||||
|
if (wantsCountGroup)
|
||||||
|
count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
|
||||||
|
else
|
||||||
|
count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
|
||||||
|
|
||||||
|
if (count != from)
|
||||||
|
return false;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DASHPOS = prop.find("-");
|
const auto DASHPOS = prop.find("-");
|
||||||
@ -403,8 +422,13 @@ bool CWorkspace::matchesStaticSelector(const std::string& selector_) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto WINDOWSONWORKSPACE = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
|
int count;
|
||||||
if (std::clamp(WINDOWSONWORKSPACE, from, to) != WINDOWSONWORKSPACE)
|
if (wantsCountGroup)
|
||||||
|
count = g_pCompositor->getGroupsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
|
||||||
|
else
|
||||||
|
count = g_pCompositor->getWindowsOnWorkspace(m_iID, wantsOnlyTiled == -1 ? std::nullopt : std::optional<bool>((bool)wantsOnlyTiled));
|
||||||
|
|
||||||
|
if (std::clamp(count, from, to) != count)
|
||||||
return false;
|
return false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user