mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 18:25:59 +01:00
hyprctl: return group list in correct order (#3683)
This commit is contained in:
parent
c619e6976f
commit
da6fa9cbd2
1 changed files with 10 additions and 17 deletions
|
@ -105,27 +105,20 @@ static std::string getGroupedData(CWindow* w, HyprCtl::eHyprCtlOutputFormat form
|
||||||
if (!w->m_sGroupData.pNextWindow)
|
if (!w->m_sGroupData.pNextWindow)
|
||||||
return isJson ? "" : "0";
|
return isJson ? "" : "0";
|
||||||
|
|
||||||
std::vector<CWindow*> groupMembers;
|
|
||||||
|
|
||||||
CWindow* curr = w;
|
|
||||||
do {
|
|
||||||
groupMembers.push_back(curr);
|
|
||||||
curr = curr->m_sGroupData.pNextWindow;
|
|
||||||
} while (curr != w);
|
|
||||||
|
|
||||||
const auto comma = isJson ? ", " : ",";
|
|
||||||
std::ostringstream result;
|
std::ostringstream result;
|
||||||
|
|
||||||
bool first = true;
|
CWindow* head = w->getGroupHead();
|
||||||
for (auto& gw : groupMembers) {
|
CWindow* curr = head;
|
||||||
if (first)
|
while (true) {
|
||||||
first = false;
|
|
||||||
else
|
|
||||||
result << comma;
|
|
||||||
if (isJson)
|
if (isJson)
|
||||||
result << std::format("\"0x{:x}\"", (uintptr_t)gw);
|
result << std::format("\"0x{:x}\"", (uintptr_t)curr);
|
||||||
else
|
else
|
||||||
result << std::format("{:x}", (uintptr_t)gw);
|
result << std::format("{:x}", (uintptr_t)curr);
|
||||||
|
curr = curr->m_sGroupData.pNextWindow;
|
||||||
|
// We've wrapped around to the start, break out without trailing comma
|
||||||
|
if (curr == head)
|
||||||
|
break;
|
||||||
|
result << (isJson ? ", " : ",");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.str();
|
return result.str();
|
||||||
|
|
Loading…
Reference in a new issue