diff options
author | Tobias Pisani <[email protected]> | 2023-11-09 17:05:05 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2023-11-09 16:05:05 +0000 |
commit | da6fa9cbd24fb45edf35cc51317392e18f682595 (patch) | |
tree | 27b105b7a585fa47c650070ea73ecee69fc5b48d | |
parent | c619e6976f8d7f9637b4bee098159935412c2e99 (diff) | |
download | Hyprland-da6fa9cbd24fb45edf35cc51317392e18f682595.tar.gz Hyprland-da6fa9cbd24fb45edf35cc51317392e18f682595.zip |
hyprctl: return group list in correct order (#3683)
-rw-r--r-- | src/debug/HyprCtl.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index b274b244..c09251a8 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -105,27 +105,20 @@ static std::string getGroupedData(CWindow* w, HyprCtl::eHyprCtlOutputFormat form if (!w->m_sGroupData.pNextWindow) 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; - bool first = true; - for (auto& gw : groupMembers) { - if (first) - first = false; - else - result << comma; + CWindow* head = w->getGroupHead(); + CWindow* curr = head; + while (true) { if (isJson) - result << std::format("\"0x{:x}\"", (uintptr_t)gw); + result << std::format("\"0x{:x}\"", (uintptr_t)curr); 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(); |