mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Use the same StatusNotifierWatcher for all trays
This commit is contained in:
@ -21,7 +21,7 @@ class Tray : public AModule {
|
||||
|
||||
static inline std::size_t nb_hosts_ = 0;
|
||||
Gtk::Box box_;
|
||||
SNI::Watcher watcher_;
|
||||
SNI::Watcher::singleton watcher_;
|
||||
SNI::Host host_;
|
||||
};
|
||||
|
||||
|
@ -7,10 +7,24 @@
|
||||
namespace waybar::modules::SNI {
|
||||
|
||||
class Watcher {
|
||||
private:
|
||||
Watcher();
|
||||
|
||||
public:
|
||||
Watcher(std::size_t id);
|
||||
~Watcher();
|
||||
|
||||
using singleton = std::shared_ptr<Watcher>;
|
||||
static singleton getInstance() {
|
||||
static std::weak_ptr<Watcher> weak;
|
||||
|
||||
std::shared_ptr<Watcher> strong = weak.lock();
|
||||
if (!strong) {
|
||||
strong = std::shared_ptr<Watcher>(new Watcher());
|
||||
weak = strong;
|
||||
}
|
||||
return strong;
|
||||
}
|
||||
|
||||
private:
|
||||
typedef enum { GF_WATCH_TYPE_HOST, GF_WATCH_TYPE_ITEM } GfWatchType;
|
||||
|
||||
@ -34,7 +48,6 @@ class Watcher {
|
||||
void updateRegisteredItems(SnWatcher *obj);
|
||||
|
||||
uint32_t bus_name_id_;
|
||||
uint32_t watcher_id_;
|
||||
GSList * hosts_ = nullptr;
|
||||
GSList * items_ = nullptr;
|
||||
SnWatcher *watcher_ = nullptr;
|
||||
|
Reference in New Issue
Block a user