diff --git a/include/modules/sni/item.hpp b/include/modules/sni/item.hpp index ee209956..6706e32b 100644 --- a/include/modules/sni/item.hpp +++ b/include/modules/sni/item.hpp @@ -63,8 +63,8 @@ class Item : public sigc::trackable { bool makeMenu(GdkEventButton* const& ev); bool handleClick(GdkEventButton* const& /*ev*/); - Glib::RefPtr cancellable_; Glib::RefPtr proxy_; + Glib::RefPtr cancellable_; bool update_pending_; }; diff --git a/include/modules/sway/mode.hpp b/include/modules/sway/mode.hpp index 36f53e14..e2c4e116 100644 --- a/include/modules/sway/mode.hpp +++ b/include/modules/sway/mode.hpp @@ -10,7 +10,7 @@ namespace waybar::modules::sway { -class Mode : public ALabel { +class Mode : public ALabel, public sigc::trackable { public: Mode(const std::string&, const Json::Value&); ~Mode() = default; diff --git a/include/modules/sway/window.hpp b/include/modules/sway/window.hpp index 20638cb5..3715eb2f 100644 --- a/include/modules/sway/window.hpp +++ b/include/modules/sway/window.hpp @@ -11,7 +11,7 @@ namespace waybar::modules::sway { -class Window : public ALabel { +class Window : public ALabel, public sigc::trackable { public: Window(const std::string&, const waybar::Bar&, const Json::Value&); ~Window() = default; diff --git a/include/modules/sway/workspaces.hpp b/include/modules/sway/workspaces.hpp index 1e0e8107..84c2eb0e 100644 --- a/include/modules/sway/workspaces.hpp +++ b/include/modules/sway/workspaces.hpp @@ -12,7 +12,7 @@ namespace waybar::modules::sway { -class Workspaces : public IModule { +class Workspaces : public IModule, public sigc::trackable { public: Workspaces(const std::string&, const waybar::Bar&, const Json::Value&); ~Workspaces() = default; diff --git a/include/util/json.hpp b/include/util/json.hpp index 3f83172f..581ad9b4 100644 --- a/include/util/json.hpp +++ b/include/util/json.hpp @@ -5,15 +5,16 @@ namespace waybar::util { struct JsonParser { - JsonParser() : reader_(builder_.newCharReader()) {} + JsonParser() {} const Json::Value parse(const std::string& data) const { Json::Value root(Json::objectValue); if (data.empty()) { return root; } - std::string err; - bool res = reader_->parse(data.c_str(), data.c_str() + data.size(), &root, &err); + std::unique_ptr const reader(builder_.newCharReader()); + std::string err; + bool res = reader->parse(data.c_str(), data.c_str() + data.size(), &root, &err); if (!res) throw std::runtime_error(err); return root; } @@ -21,8 +22,7 @@ struct JsonParser { ~JsonParser() = default; private: - Json::CharReaderBuilder builder_; - std::unique_ptr const reader_; + Json::CharReaderBuilder builder_; }; } // namespace waybar::util diff --git a/src/modules/sni/watcher.cpp b/src/modules/sni/watcher.cpp index 42cfe2a3..1ba1324f 100644 --- a/src/modules/sni/watcher.cpp +++ b/src/modules/sni/watcher.cpp @@ -14,11 +14,6 @@ Watcher::Watcher() watcher_(sn_watcher_skeleton_new()) {} Watcher::~Watcher() { - if (bus_name_id_ != 0) { - Gio::DBus::unown_name(bus_name_id_); - bus_name_id_ = 0; - } - if (hosts_ != nullptr) { g_slist_free_full(hosts_, gfWatchFree); hosts_ = nullptr; diff --git a/src/modules/sway/workspaces.cpp b/src/modules/sway/workspaces.cpp index 50be8d94..f379c9aa 100644 --- a/src/modules/sway/workspaces.cpp +++ b/src/modules/sway/workspaces.cpp @@ -19,7 +19,13 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value worker(); } -void Workspaces::onEvent(const struct Ipc::ipc_response &res) { ipc_.sendCmd(IPC_GET_WORKSPACES); } +void Workspaces::onEvent(const struct Ipc::ipc_response &res) { + try { + ipc_.sendCmd(IPC_GET_WORKSPACES); + } catch (const std::exception &e) { + std::cerr << "Workspaces: " << e.what() << std::endl; + } +} void Workspaces::onCmd(const struct Ipc::ipc_response &res) { if (res.type == IPC_GET_WORKSPACES) { @@ -194,7 +200,11 @@ bool Workspaces::handleScroll(GdkEventScroll *e) { return false; } } - ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name)); + try { + ipc_.sendCmd(IPC_COMMAND, fmt::format("workspace \"{}\"", name)); + } catch (const std::exception &e) { + std::cerr << "Workspaces: " << e.what() << std::endl; + } return true; }