niri/window: add col/max_col parameters

niri v25.08 added window positions to IPC, so waybar actually has the
information stored in json around.

This handles the associated WindowLayoutsChanged IPC message to keep the
position up to date in memory, and adds a couple of format messages to
show the current column, so one can dislpay where we are in the
workspace (in the hope of improving this feeling of being lost...)

Ideally a visual representation of the workspace like the one
illustrated in the PR[1] would be even better but this will probably do
for now.

Link: https://github.com/YaLTeR/niri/pull/1265#issuecomment-2724621758 [1]
This commit is contained in:
Dominique Martinet
2025-10-07 22:56:30 +09:00
parent 559079e9a6
commit 632e30eb9f
3 changed files with 28 additions and 1 deletions
+12
View File
@@ -202,6 +202,18 @@ void IPC::parseIPC(const std::string &line) {
for (auto &win : windows_) {
win["is_focused"] = focused && win["id"].asUInt64() == id;
}
} else if (const auto &payload = ev["WindowLayoutsChanged"]) {
const auto &values = payload["changes"];
for (const auto &changed : values) {
const auto id = changed[0].asUInt64();
const auto &change = changed[1];
for (auto &win : windows_) {
if (win["id"].asUInt64() == id) {
win["layout"] = change;
break;
}
}
}
}
}