From 737da3615f1deaa029977372c36635698aa53865 Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 3 Mar 2019 21:35:32 +1100 Subject: [PATCH] resolves #205 --- include/modules/sway/workspaces.hpp | 1 + src/modules/sway/workspaces.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/modules/sway/workspaces.hpp b/include/modules/sway/workspaces.hpp index d244505..c373f33 100644 --- a/include/modules/sway/workspaces.hpp +++ b/include/modules/sway/workspaces.hpp @@ -20,6 +20,7 @@ class Workspaces : public IModule { private: void worker(); void addWorkspace(const Json::Value&); + void onButtonReady(const Json::Value&, Gtk::Button&); std::string getIcon(const std::string&, const Json::Value&); bool handleScroll(GdkEventScroll*); std::string getPrevWorkspace(); diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 598590a..d66b622 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -87,7 +87,8 @@ auto waybar::modules::sway::Workspaces::update() -> void } else { button.set_label(icon); } - button.show(); + + onButtonReady(node, button); } } if (scrolling_) { @@ -131,7 +132,8 @@ void waybar::modules::sway::Workspaces::addWorkspace(const Json::Value &node) if (node["urgent"].asBool()) { button.get_style_context()->add_class("urgent"); } - button.show(); + + onButtonReady(node, button); } std::string waybar::modules::sway::Workspaces::getIcon(const std::string &name, @@ -251,6 +253,19 @@ std::string waybar::modules::sway::Workspaces::trimWorkspaceName(std::string nam return name; } +void waybar::modules::sway::Workspaces::onButtonReady(const Json::Value& node, Gtk::Button& button) +{ + if (config_["current-only"].asBool()) { + if (node["focused"].asBool()) { + button.show(); + } else { + button.hide(); + } + } else { + button.show(); + } +} + waybar::modules::sway::Workspaces::operator Gtk::Widget &() { return box_; }