sway/workspaces: support ignore window-rewrite

Similar to hyprland implementation to ignore "" empty rules
This commit is contained in:
Austin Horstman 2024-07-16 22:48:25 -05:00
parent 9c40137d05
commit 90ac7d5d2c
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View File

@ -87,6 +87,7 @@ warp-on-scroll: ++
Regex rules to map window class to an icon or preferred method of representation for a workspace's window. Regex rules to map window class to an icon or preferred method of representation for a workspace's window.
Keys are the rules, while the values are the methods of representation. Keys are the rules, while the values are the methods of representation.
Rules may specify `class<...>`, `title<...>`, or both in order to fine-tune the matching. Rules may specify `class<...>`, `title<...>`, or both in order to fine-tune the matching.
You may assign an empty value to a rule to have it ignored from generating any representation in workspaces.
*window-rewrite-default*: *window-rewrite-default*:
typeof: string ++ typeof: string ++

View File

@ -261,13 +261,17 @@ void Workspaces::updateWindows(const Json::Value &node, std::string &windows) {
node["name"].isString()) { node["name"].isString()) {
std::string title = g_markup_escape_text(node["name"].asString().c_str(), -1); std::string title = g_markup_escape_text(node["name"].asString().c_str(), -1);
std::string windowClass = node["app_id"].asString(); std::string windowClass = node["app_id"].asString();
std::string windowReprKey = fmt::format("class<{}> title<{}>", windowClass, title);
std::string window = m_windowRewriteRules.get(windowReprKey); // Only add window rewrites that can be looked up
// allow result to have formatting if (!windowClass.empty()) {
window = std::string windowReprKey = fmt::format("class<{}> title<{}>", windowClass, title);
fmt::format(fmt::runtime(window), fmt::arg("name", title), fmt::arg("class", windowClass)); std::string window = m_windowRewriteRules.get(windowReprKey);
windows.append(window); // allow result to have formatting
windows.append(m_formatWindowSeperator); window = fmt::format(fmt::runtime(window), fmt::arg("name", title),
fmt::arg("class", windowClass));
windows.append(window);
windows.append(m_formatWindowSeperator);
}
} }
for (const Json::Value &child : node["nodes"]) { for (const Json::Value &child : node["nodes"]) {
updateWindows(child, windows); updateWindows(child, windows);