feat(Bar): handle widget size changes

This commit is contained in:
Alex
2019-04-24 12:37:24 +02:00
parent 90d89fe974
commit 311c34ecbc
28 changed files with 175 additions and 137 deletions

View File

@ -12,7 +12,7 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
label_.set_hexpand(true);
label_.set_ellipsize(Pango::EllipsizeMode::ELLIPSIZE_END);
}
ipc_.subscribe("[\"window\",\"workspace\"]");
ipc_.subscribe(R"(["window","workspace"])");
ipc_.signal_event.connect(sigc::mem_fun(*this, &Window::onEvent));
ipc_.signal_cmd.connect(sigc::mem_fun(*this, &Window::onCmd));
getFocusedWindow();
@ -20,7 +20,7 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
worker();
}
void Window::onEvent(const struct Ipc::ipc_response res) {
void Window::onEvent(const struct Ipc::ipc_response& res) {
auto data = res.payload;
// Check for waybar prevents flicker when hovering window module
if ((data["change"] == "focus" || data["change"] == "title") &&
@ -38,7 +38,7 @@ void Window::onEvent(const struct Ipc::ipc_response res) {
}
}
void Window::onCmd(const struct Ipc::ipc_response res) {
void Window::onCmd(const struct Ipc::ipc_response& res) {
auto [id, name] = getFocusedNode(res.payload["nodes"]);
windowId_ = id;
window_ = name;
@ -62,7 +62,7 @@ auto Window::update() -> void {
}
}
std::tuple<int, std::string> Window::getFocusedNode(Json::Value nodes) {
std::tuple<int, std::string> Window::getFocusedNode(const Json::Value& nodes) {
for (auto const& node : nodes) {
if (node["focused"].asBool() && node["type"] == "con") {
return {node["id"].asInt(), node["name"].asString()};