diff --git a/include/common.hpp b/include/common.hpp index b8afaea7..23f1dbbb 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -4,12 +4,8 @@ #define BOOST_DI_CFG_DIAGNOSTICS_LEVEL 2 #endif -#include -#include -#include #include #include -#include #include "config.hpp" @@ -41,7 +37,6 @@ POLYBAR_NS -namespace di = boost::di; namespace placeholders = std::placeholders; using std::string; @@ -58,7 +53,6 @@ using std::make_unique; using std::make_shared; using std::make_pair; using std::array; -using std::map; using std::vector; using std::to_string; diff --git a/include/components/bar.hpp b/include/components/bar.hpp index 3d7e69fb..d06d6d7d 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -2,12 +2,16 @@ #include "common.hpp" #include "components/config.hpp" +#include "components/screen.hpp" #include "components/types.hpp" #include "errors.hpp" +#include "events/signal_emitter.hpp" +#include "events/signal_fwd.hpp" #include "utils/concurrency.hpp" #include "utils/throttle.hpp" #include "x11/connection.hpp" #include "x11/events.hpp" +#include "x11/tray_manager.hpp" #include "x11/types.hpp" #include "x11/window.hpp" @@ -21,20 +25,16 @@ class renderer; class bar : public xpp::event::sink { public: - explicit bar(connection& conn, const config& config, const logger& logger, unique_ptr screen, unique_ptr tray_manager); - ~bar(); + explicit bar(connection& conn, signal_emitter& emitter, const config& config, const logger& logger, + unique_ptr screen, unique_ptr tray_manager); - void bootstrap(bool nodraw = false); - void bootstrap_tray(); - void activate_tray(); + ~bar(); const bar_settings settings() const; void parse(const string& data, bool force = false); protected: - void setup_monitor(); - void configure_geom(); void restack_window(); void reconfigure_pos(); void reconfigure_struts(); @@ -47,22 +47,37 @@ class bar : public xpp::event::sink m_screen; unique_ptr m_tray; unique_ptr m_renderer; - xcb_window_t m_window; bar_settings m_opts; string m_lastinput; std::mutex m_mutex; - event_timer m_buttonpress{}; + event_timer m_buttonpress{0L, 5L}; }; -di::injector> configure_bar(); +namespace { + /** + * Configure bar controller + */ + inline unique_ptr make_bar() { + // clang-format off + return factory_util::unique( + make_connection(), + make_signal_emitter(), + make_confreader(), + make_logger(), + make_screen(), + make_tray_manager()); + // clang-format on + } +} POLYBAR_NS_END diff --git a/include/components/builder.hpp b/include/components/builder.hpp index d9533286..b7ec348b 100644 --- a/include/components/builder.hpp +++ b/include/components/builder.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "common.hpp" #include "components/config.hpp" #include "components/types.hpp" @@ -7,6 +9,8 @@ POLYBAR_NS +using std::map; + #define DEFAULT_SPACING -1 #ifndef BUILDER_SPACE_TOKEN @@ -28,7 +32,7 @@ class builder { explicit builder(const bar_settings bar) : m_bar(bar) {} string flush(); - void append(string text); + void append(const string& text); void node(string str, bool add_space = false); void node(string str, int font_index, bool add_space = false); void node(const label_t& label, bool add_space = false); diff --git a/include/components/command_line.hpp b/include/components/command_line.hpp index 50ebd880..bf6221ca 100644 --- a/include/components/command_line.hpp +++ b/include/components/command_line.hpp @@ -1,7 +1,10 @@ #pragma once +#include + #include "common.hpp" #include "errors.hpp" +#include "utils/factory.hpp" POLYBAR_NS @@ -12,7 +15,7 @@ namespace command_line { class option; using choices = vector; using options = vector