Separate workspace groups for outputs
parent
b34d325a71
commit
e9144af852
|
@ -30,6 +30,7 @@ class Workspaces : public AModule, public sigc::trackable {
|
||||||
|
|
||||||
void onCmd(const struct Ipc::ipc_response&);
|
void onCmd(const struct Ipc::ipc_response&);
|
||||||
void onEvent(const struct Ipc::ipc_response&);
|
void onEvent(const struct Ipc::ipc_response&);
|
||||||
|
bool isShown(const Json::Value&);
|
||||||
bool filterButtons();
|
bool filterButtons();
|
||||||
Gtk::Button& addButton(const Json::Value&);
|
Gtk::Button& addButton(const Json::Value&);
|
||||||
void onButtonReady(const Json::Value&, Gtk::Button&);
|
void onButtonReady(const Json::Value&, Gtk::Button&);
|
||||||
|
|
|
@ -60,6 +60,23 @@ void Workspaces::onEvent(const struct Ipc::ipc_response &res) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read the configuration on whether the given workspace should be shown by the
|
||||||
|
// module
|
||||||
|
bool Workspaces::isShown(const Json::Value &workspace) {
|
||||||
|
if (config_["all-outputs"].asBool()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Json::String outputShown;
|
||||||
|
if (config_["for-output"].isString()) {
|
||||||
|
outputShown = config_["for-output"].asString();
|
||||||
|
} else {
|
||||||
|
// Show workspaces of the output on which the bar is shown
|
||||||
|
outputShown = bar_.output->name;
|
||||||
|
}
|
||||||
|
return workspace["output"].asString() == outputShown;
|
||||||
|
}
|
||||||
|
|
||||||
void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
|
void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
|
||||||
if (res.type == IPC_GET_WORKSPACES) {
|
if (res.type == IPC_GET_WORKSPACES) {
|
||||||
try {
|
try {
|
||||||
|
@ -68,11 +85,7 @@ void Workspaces::onCmd(const struct Ipc::ipc_response &res) {
|
||||||
auto payload = parser_.parse(res.payload);
|
auto payload = parser_.parse(res.payload);
|
||||||
workspaces_.clear();
|
workspaces_.clear();
|
||||||
std::copy_if(payload.begin(), payload.end(), std::back_inserter(workspaces_),
|
std::copy_if(payload.begin(), payload.end(), std::back_inserter(workspaces_),
|
||||||
[&](const auto &workspace) {
|
[&](const auto &workspace) { return isShown(workspace); });
|
||||||
return !config_["all-outputs"].asBool()
|
|
||||||
? workspace["output"].asString() == bar_.output->name
|
|
||||||
: true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// adding persistent workspaces (as per the config file)
|
// adding persistent workspaces (as per the config file)
|
||||||
if (config_["persistent_workspaces"].isObject()) {
|
if (config_["persistent_workspaces"].isObject()) {
|
||||||
|
@ -178,8 +191,7 @@ bool Workspaces::filterButtons() {
|
||||||
for (auto it = buttons_.begin(); it != buttons_.end();) {
|
for (auto it = buttons_.begin(); it != buttons_.end();) {
|
||||||
auto ws = std::find_if(workspaces_.begin(), workspaces_.end(),
|
auto ws = std::find_if(workspaces_.begin(), workspaces_.end(),
|
||||||
[it](const auto &node) { return node["name"].asString() == it->first; });
|
[it](const auto &node) { return node["name"].asString() == it->first; });
|
||||||
if (ws == workspaces_.end() ||
|
if (ws == workspaces_.end() || !isShown(*ws)) {
|
||||||
(!config_["all-outputs"].asBool() && (*ws)["output"].asString() != bar_.output->name)) {
|
|
||||||
it = buttons_.erase(it);
|
it = buttons_.erase(it);
|
||||||
needReorder = true;
|
needReorder = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue