refactor(modules): const bar
parent
281bab4943
commit
691fb88057
|
@ -26,7 +26,6 @@ class Bar {
|
||||||
std::string output_name;
|
std::string output_name;
|
||||||
uint32_t wl_name;
|
uint32_t wl_name;
|
||||||
bool visible = true;
|
bool visible = true;
|
||||||
uint32_t nb_tray_hosts = 0;
|
|
||||||
private:
|
private:
|
||||||
static void handleLogicalPosition(void *, struct zxdg_output_v1 *, int32_t,
|
static void handleLogicalPosition(void *, struct zxdg_output_v1 *, int32_t,
|
||||||
int32_t);
|
int32_t);
|
||||||
|
|
|
@ -27,10 +27,10 @@ class Bar;
|
||||||
|
|
||||||
class Factory {
|
class Factory {
|
||||||
public:
|
public:
|
||||||
Factory(Bar& bar, const Json::Value& config);
|
Factory(const Bar& bar, const Json::Value& config);
|
||||||
IModule* makeModule(const std::string &name) const;
|
IModule* makeModule(const std::string &name) const;
|
||||||
private:
|
private:
|
||||||
Bar& bar_;
|
const Bar& bar_;
|
||||||
const Json::Value& config_;
|
const Json::Value& config_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,14 @@ namespace waybar::modules::SNI {
|
||||||
|
|
||||||
class Tray : public IModule {
|
class Tray : public IModule {
|
||||||
public:
|
public:
|
||||||
Tray(Bar& bar, const Json::Value&);
|
Tray(const Bar& bar, const Json::Value&);
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
operator Gtk::Widget &();
|
operator Gtk::Widget &();
|
||||||
private:
|
private:
|
||||||
void onAdd(std::unique_ptr<Item>& item);
|
void onAdd(std::unique_ptr<Item>& item);
|
||||||
void onRemove(std::unique_ptr<Item>& item);
|
void onRemove(std::unique_ptr<Item>& item);
|
||||||
|
|
||||||
|
static inline std::size_t nb_hosts_ = 0;
|
||||||
std::thread thread_;
|
std::thread thread_;
|
||||||
const Json::Value& config_;
|
const Json::Value& config_;
|
||||||
Gtk::Box box_;
|
Gtk::Box box_;
|
||||||
|
|
|
@ -12,12 +12,12 @@ namespace waybar::modules::sway {
|
||||||
|
|
||||||
class Mode : public ALabel {
|
class Mode : public ALabel {
|
||||||
public:
|
public:
|
||||||
Mode(waybar::Bar&, const Json::Value&);
|
Mode(const waybar::Bar&, const Json::Value&);
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
private:
|
private:
|
||||||
void worker();
|
void worker();
|
||||||
|
|
||||||
Bar& bar_;
|
const Bar& bar_;
|
||||||
waybar::util::SleeperThread thread_;
|
waybar::util::SleeperThread thread_;
|
||||||
util::JsonParser parser_;
|
util::JsonParser parser_;
|
||||||
Ipc ipc_;
|
Ipc ipc_;
|
||||||
|
|
|
@ -13,14 +13,14 @@ namespace waybar::modules::sway {
|
||||||
|
|
||||||
class Window : public ALabel {
|
class Window : public ALabel {
|
||||||
public:
|
public:
|
||||||
Window(waybar::Bar&, const Json::Value&);
|
Window(const waybar::Bar&, const Json::Value&);
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
private:
|
private:
|
||||||
void worker();
|
void worker();
|
||||||
std::tuple<int, std::string> getFocusedNode(Json::Value nodes);
|
std::tuple<int, std::string> getFocusedNode(Json::Value nodes);
|
||||||
void getFocusedWindow();
|
void getFocusedWindow();
|
||||||
|
|
||||||
Bar& bar_;
|
const Bar& bar_;
|
||||||
waybar::util::SleeperThread thread_;
|
waybar::util::SleeperThread thread_;
|
||||||
util::JsonParser parser_;
|
util::JsonParser parser_;
|
||||||
Ipc ipc_;
|
Ipc ipc_;
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace waybar::modules::sway {
|
||||||
|
|
||||||
class Workspaces : public IModule {
|
class Workspaces : public IModule {
|
||||||
public:
|
public:
|
||||||
Workspaces(waybar::Bar&, const Json::Value&);
|
Workspaces(const waybar::Bar&, const Json::Value&);
|
||||||
auto update() -> void;
|
auto update() -> void;
|
||||||
operator Gtk::Widget &();
|
operator Gtk::Widget &();
|
||||||
private:
|
private:
|
||||||
|
@ -23,7 +23,7 @@ class Workspaces : public IModule {
|
||||||
std::string getPrevWorkspace();
|
std::string getPrevWorkspace();
|
||||||
std::string getNextWorkspace();
|
std::string getNextWorkspace();
|
||||||
|
|
||||||
Bar& bar_;
|
const Bar& bar_;
|
||||||
const Json::Value& config_;
|
const Json::Value& config_;
|
||||||
waybar::util::SleeperThread thread_;
|
waybar::util::SleeperThread thread_;
|
||||||
Gtk::Box box_;
|
Gtk::Box box_;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "factory.hpp"
|
#include "factory.hpp"
|
||||||
|
|
||||||
waybar::Factory::Factory(Bar& bar, const Json::Value& config)
|
waybar::Factory::Factory(const Bar& bar, const Json::Value& config)
|
||||||
: bar_(bar), config_(config)
|
: bar_(bar), config_(config)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
waybar::modules::SNI::Tray::Tray(Bar& bar, const Json::Value &config)
|
waybar::modules::SNI::Tray::Tray(const Bar& bar, const Json::Value &config)
|
||||||
: config_(config), watcher_(), host_(bar.nb_tray_hosts, config,
|
: config_(config), watcher_(), host_(nb_hosts_, config,
|
||||||
std::bind(&Tray::onAdd, this, std::placeholders::_1),
|
std::bind(&Tray::onAdd, this, std::placeholders::_1),
|
||||||
std::bind(&Tray::onRemove, this, std::placeholders::_1))
|
std::bind(&Tray::onRemove, this, std::placeholders::_1))
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ waybar::modules::SNI::Tray::Tray(Bar& bar, const Json::Value &config)
|
||||||
if (config_["spacing"].isUInt()) {
|
if (config_["spacing"].isUInt()) {
|
||||||
box_.set_spacing(config_["spacing"].asUInt());
|
box_.set_spacing(config_["spacing"].asUInt());
|
||||||
}
|
}
|
||||||
bar.nb_tray_hosts += 1;
|
nb_hosts_ += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waybar::modules::SNI::Tray::onAdd(std::unique_ptr<Item>& item)
|
void waybar::modules::SNI::Tray::onAdd(std::unique_ptr<Item>& item)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "modules/sway/mode.hpp"
|
#include "modules/sway/mode.hpp"
|
||||||
|
|
||||||
waybar::modules::sway::Mode::Mode(Bar& bar, const Json::Value& config)
|
waybar::modules::sway::Mode::Mode(const Bar& bar, const Json::Value& config)
|
||||||
: ALabel(config, "{}"), bar_(bar)
|
: ALabel(config, "{}"), bar_(bar)
|
||||||
{
|
{
|
||||||
ipc_.connect();
|
ipc_.connect();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "modules/sway/window.hpp"
|
#include "modules/sway/window.hpp"
|
||||||
|
|
||||||
waybar::modules::sway::Window::Window(Bar &bar, const Json::Value& config)
|
waybar::modules::sway::Window::Window(const Bar &bar, const Json::Value& config)
|
||||||
: ALabel(config, "{}"), bar_(bar), windowId_(-1)
|
: ALabel(config, "{}"), bar_(bar), windowId_(-1)
|
||||||
{
|
{
|
||||||
label_.set_name("window");
|
label_.set_name("window");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "modules/sway/workspaces.hpp"
|
#include "modules/sway/workspaces.hpp"
|
||||||
|
|
||||||
waybar::modules::sway::Workspaces::Workspaces(Bar& bar,
|
waybar::modules::sway::Workspaces::Workspaces(const Bar& bar,
|
||||||
const Json::Value& config)
|
const Json::Value& config)
|
||||||
: bar_(bar), config_(config), scrolling_(false)
|
: bar_(bar), config_(config), scrolling_(false)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue