Merge pull request #4530 from martinetd/niri-column
[RFC] niri/window: add col/max_col parameters
This commit is contained in:
@@ -48,6 +48,10 @@ See the output of "niri msg windows" for examples
|
|||||||
|
|
||||||
*{app_id}*: The current app ID of the focused window.
|
*{app_id}*: The current app ID of the focused window.
|
||||||
|
|
||||||
|
*{col}*: The current column of the focused window in the workspace.
|
||||||
|
|
||||||
|
*{max_col}*: The maximum column inside the workspace of the focused window.
|
||||||
|
|
||||||
# REWRITE RULES
|
# REWRITE RULES
|
||||||
|
|
||||||
*rewrite* is an object where keys are regular expressions and values are
|
*rewrite* is an object where keys are regular expressions and values are
|
||||||
|
|||||||
@@ -196,6 +196,18 @@ void IPC::parseIPC(const std::string& line) {
|
|||||||
for (auto& win : windows_) {
|
for (auto& win : windows_) {
|
||||||
win["is_focused"] = focused && win["id"].asUInt64() == id;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
|
|||||||
gIPC->registerForIPC("WindowOpenedOrChanged", this);
|
gIPC->registerForIPC("WindowOpenedOrChanged", this);
|
||||||
gIPC->registerForIPC("WindowClosed", this);
|
gIPC->registerForIPC("WindowClosed", this);
|
||||||
gIPC->registerForIPC("WindowFocusChanged", this);
|
gIPC->registerForIPC("WindowFocusChanged", this);
|
||||||
|
gIPC->registerForIPC("WindowLayoutsChanged", this);
|
||||||
|
|
||||||
dp.emit();
|
dp.emit();
|
||||||
}
|
}
|
||||||
@@ -54,15 +55,25 @@ void Window::doUpdate() {
|
|||||||
if (it != windows.cend()) {
|
if (it != windows.cend()) {
|
||||||
const auto& window = *it;
|
const auto& window = *it;
|
||||||
|
|
||||||
|
auto max_col = -1;
|
||||||
|
for (const auto &win : windows) {
|
||||||
|
if (win["workspace_id"].asUInt64() != window["workspace_id"].asUInt64()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const auto col = win["layout"]["pos_in_scrolling_layout"][0].asInt64();
|
||||||
|
if (col > max_col) max_col = col;
|
||||||
|
}
|
||||||
const auto title = window["title"].asString();
|
const auto title = window["title"].asString();
|
||||||
const auto appId = window["app_id"].asString();
|
const auto appId = window["app_id"].asString();
|
||||||
|
const auto col = window["layout"]["pos_in_scrolling_layout"][0].asInt64();
|
||||||
const auto sanitizedTitle = waybar::util::sanitize_string(title);
|
const auto sanitizedTitle = waybar::util::sanitize_string(title);
|
||||||
const auto sanitizedAppId = waybar::util::sanitize_string(appId);
|
const auto sanitizedAppId = waybar::util::sanitize_string(appId);
|
||||||
|
|
||||||
label_.show();
|
label_.show();
|
||||||
label_.set_markup(waybar::util::rewriteString(
|
label_.set_markup(waybar::util::rewriteString(
|
||||||
fmt::format(fmt::runtime(format_), fmt::arg("title", sanitizedTitle),
|
fmt::format(fmt::runtime(format_), fmt::arg("title", sanitizedTitle),
|
||||||
fmt::arg("app_id", sanitizedAppId)),
|
fmt::arg("app_id", sanitizedAppId), fmt::arg("col", col),
|
||||||
|
fmt::arg("max_col", max_col)),
|
||||||
config_["rewrite"]));
|
config_["rewrite"]));
|
||||||
|
|
||||||
updateAppIconName(appId, "");
|
updateAppIconName(appId, "");
|
||||||
|
|||||||
Reference in New Issue
Block a user