Merge pull request #4001 from hansp27/niri-workspaces-display-preference
feat: add display-condition configuration option
This commit is contained in:
@@ -68,6 +68,16 @@ If none of the sorting options are enabled, workspaces keep their output/index o
|
|||||||
default: false ++
|
default: false ++
|
||||||
If set to true, only the active or focused workspace will be shown.
|
If set to true, only the active or focused workspace will be shown.
|
||||||
|
|
||||||
|
*display-condition*: ++
|
||||||
|
typeof: string ++
|
||||||
|
oneof: "show-all", "keep-named", "only-populated" ++
|
||||||
|
default: "show-all" ++
|
||||||
|
Specifies the conditions for showing workspace widgets. ++
|
||||||
|
++
|
||||||
|
*show-all*: displays widgets for all workspaces. ++
|
||||||
|
*keep-named*: always displays named workspaces, irrespective of whether they contain windows or not. ++
|
||||||
|
*only-populated*: only displays widgets for workspaces that have windows.
|
||||||
|
|
||||||
*hide-empty*: ++
|
*hide-empty*: ++
|
||||||
typeof: bool ++
|
typeof: bool ++
|
||||||
default: false ++
|
default: false ++
|
||||||
|
|||||||
@@ -81,9 +81,11 @@ void Workspaces::doUpdate() {
|
|||||||
auto ipcLock = gIPC->lockData();
|
auto ipcLock = gIPC->lockData();
|
||||||
|
|
||||||
const auto alloutputs = config_["all-outputs"].asBool();
|
const auto alloutputs = config_["all-outputs"].asBool();
|
||||||
|
const auto display_cond = config_["display-condition"].asString();
|
||||||
std::vector<Json::Value> my_workspaces;
|
std::vector<Json::Value> my_workspaces;
|
||||||
const auto& workspaces = gIPC->workspaces();
|
const auto& workspaces = gIPC->workspaces();
|
||||||
std::copy_if(workspaces.cbegin(), workspaces.cend(), std::back_inserter(my_workspaces),
|
std::copy_if(
|
||||||
|
workspaces.cbegin(), workspaces.cend(), std::back_inserter(my_workspaces),
|
||||||
[&](const auto& ws) {
|
[&](const auto& ws) {
|
||||||
std::string name;
|
std::string name;
|
||||||
if (ws["name"]) {
|
if (ws["name"]) {
|
||||||
@@ -95,6 +97,13 @@ void Workspaces::doUpdate() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (display_cond == "only-populated") {
|
||||||
|
if (ws["active_window_id"].isNull() && !ws["is_active"].asBool()) return false;
|
||||||
|
} else if (display_cond == "keep-named") {
|
||||||
|
if (ws["name"].isNull() && ws["active_window_id"].isNull() && !ws["is_active"].asBool())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (alloutputs) return true;
|
if (alloutputs) return true;
|
||||||
return ws["output"].asString() == bar_.output->name;
|
return ws["output"].asString() == bar_.output->name;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user