diff --git a/include/components/bar.hpp b/include/components/bar.hpp index 2fcf1ff1..ec71d817 100644 --- a/include/components/bar.hpp +++ b/include/components/bar.hpp @@ -15,10 +15,7 @@ POLYBAR_NS -namespace chrono = std::chrono; -using namespace std::chrono_literals; - -// fwd +// fwd {{{ class config; class connection; class logger; @@ -28,14 +25,12 @@ class screen; class signal_emitter; class taskqueue; class tray_manager; - -namespace sig_ui = signals::ui; -namespace sig_ev = signals::eventqueue; +// }}} class bar : public xpp::event::sink, - public signal_receiver { + public signal_receiver { public: using make_type = unique_ptr; static make_type make(bool only_initialize_values = false); @@ -63,11 +58,11 @@ class bar : public xpp::event::sink; using modulemap_t = std::map>; // }}} -using std::thread; -namespace chrono = std::chrono; -using namespace std::chrono_literals; - -namespace sig_ev = signals::eventqueue; -namespace sig_ui = signals::ui; -namespace sig_ipc = signals::ipc; - -class controller : public signal_receiver { +class controller : public signal_receiver { public: using make_type = unique_ptr; static make_type make(unique_ptr&& ipc, unique_ptr&& config_watch); @@ -66,15 +56,15 @@ class controller : public signal_receiver; - queue_t m_queue; + moodycamel::BlockingConcurrentQueue m_queue; /** * @brief Loaded modules @@ -117,17 +106,17 @@ class controller : public signal_receiver m_lastinput; + std::chrono::time_point m_lastinput; /** * @brief Input data @@ -137,7 +126,7 @@ class controller : public signal_receiver public {{{ @@ -61,7 +59,7 @@ namespace modules { CAST_MOD(Impl)->wakeup(); CAST_MOD(Impl)->teardown(); - m_sig.emit(sig_ev::check_state{}); + m_sig.emit(signals::eventqueue::check_state{}); } } @@ -91,7 +89,7 @@ namespace modules { template void module::broadcast() { m_changed = true; - m_sig.emit(sig_ev::notify_change{}); + m_sig.emit(signals::eventqueue::notify_change{}); } template diff --git a/src/components/bar.cpp b/src/components/bar.cpp index 57ea3514..c1aedd1b 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -477,7 +477,7 @@ void bar::handle(const evt::destroy_notify& evt) { void bar::handle(const evt::enter_notify&) { #if DEBUG if (m_opts.origin == edge::TOP) { - m_taskqueue->defer_unique("window-hover", 25ms, [&](size_t) { m_sig.emit(sig_ui::unshade_window{}); }); + m_taskqueue->defer_unique("window-hover", 25ms, [&](size_t) { m_sig.emit(signals::ui::unshade_window{}); }); return; } #endif @@ -501,7 +501,7 @@ void bar::handle(const evt::enter_notify&) { void bar::handle(const evt::leave_notify&) { #if DEBUG if (m_opts.origin == edge::TOP) { - m_taskqueue->defer_unique("window-hover", 25ms, [&](size_t) { m_sig.emit(sig_ui::shade_window{}); }); + m_taskqueue->defer_unique("window-hover", 25ms, [&](size_t) { m_sig.emit(signals::ui::shade_window{}); }); return; } #endif @@ -614,14 +614,14 @@ void bar::handle(const evt::property_notify& evt) { } } -bool bar::on(const sig_ev::start&) { +bool bar::on(const signals::eventqueue::start&) { m_log.trace("bar: Setup tray manager"); m_tray->setup(static_cast(m_opts)); broadcast_visibility(); return true; } -bool bar::on(const sig_ui::unshade_window&) { +bool bar::on(const signals::ui::unshade_window&) { m_opts.shaded = false; m_opts.shade_size.w = m_opts.size.w; m_opts.shade_size.h = m_opts.size.h; @@ -635,7 +635,7 @@ bool bar::on(const sig_ui::unshade_window&) { m_taskqueue->defer_unique("window-shade", 25ms, [&](size_t remaining) { if (!m_opts.shaded) { - m_sig.emit(sig_ui::tick{}); + m_sig.emit(signals::ui::tick{}); } if (!remaining) { m_renderer->flush(false); @@ -650,7 +650,7 @@ bool bar::on(const sig_ui::unshade_window&) { return true; } -bool bar::on(const sig_ui::shade_window&) { +bool bar::on(const signals::ui::shade_window&) { taskqueue::deferred::duration offset{2000ms}; if (!m_opts.shaded && m_opts.shade_size.h != m_opts.size.h) { @@ -674,7 +674,7 @@ bool bar::on(const sig_ui::shade_window&) { m_taskqueue->defer_unique("window-shade", 25ms, [&](size_t remaining) { if (m_opts.shaded) { - m_sig.emit(sig_ui::tick{}); + m_sig.emit(signals::ui::tick{}); } if (!remaining) { m_renderer->flush(false); @@ -689,7 +689,7 @@ bool bar::on(const sig_ui::shade_window&) { return true; } -bool bar::on(const sig_ui::tick&) { +bool bar::on(const signals::ui::tick&) { auto geom = m_connection.get_geometry(m_opts.window); if (geom->y == m_opts.shade_pos.y && geom->height == m_opts.shade_size.h) { return false; @@ -723,7 +723,7 @@ bool bar::on(const sig_ui::tick&) { return false; } -bool bar::on(const sig_ui::dim_window& sig) { +bool bar::on(const signals::ui::dim_window& sig) { m_opts.dimmed = sig.cast() != 1.0; set_wm_window_opacity(m_connection, m_opts.window, sig.cast() * 0xFFFFFFFF); m_connection.flush(); diff --git a/src/components/controller.cpp b/src/components/controller.cpp index 0406f5a3..6dd61f24 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -326,9 +326,9 @@ void controller::process_eventqueue() { break; } else if (evt.type == event_type::QUIT) { if (evt.flag) { - on(sig_ev::exit_reload{}); + on(signals::eventqueue::exit_reload{}); } else { - on(sig_ev::exit_terminate{}); + on(signals::eventqueue::exit_terminate{}); } } else if (evt.type == event_type::INPUT) { process_inputdata(); @@ -359,12 +359,12 @@ void controller::process_eventqueue() { process_inputdata(); } else if (evt.type == event_type::QUIT) { if (evt.flag) { - on(sig_ev::exit_reload{}); + on(signals::eventqueue::exit_reload{}); } else { - on(sig_ev::exit_terminate{}); + on(signals::eventqueue::exit_terminate{}); } } else if (evt.type == event_type::CHECK) { - on(sig_ev::check_state{}); + on(signals::eventqueue::check_state{}); } else { m_log.warn("Unknown event type for enqueued event (%d)", evt.type); } @@ -497,21 +497,21 @@ bool controller::process_update(bool force) { /** * Process broadcast events */ -bool controller::on(const sig_ev::notify_change&) { +bool controller::on(const signals::eventqueue::notify_change&) { return enqueue(make_update_evt(false)); } /** * Process forced broadcast events */ -bool controller::on(const sig_ev::notify_forcechange&) { +bool controller::on(const signals::eventqueue::notify_forcechange&) { return enqueue(make_update_evt(true)); } /** * Process eventqueue terminate event */ -bool controller::on(const sig_ev::exit_terminate&) { +bool controller::on(const signals::eventqueue::exit_terminate&) { raise(SIGALRM); return true; } @@ -519,7 +519,7 @@ bool controller::on(const sig_ev::exit_terminate&) { /** * Process eventqueue reload event */ -bool controller::on(const sig_ev::exit_reload&) { +bool controller::on(const signals::eventqueue::exit_reload&) { raise(SIGUSR1); return true; } @@ -527,7 +527,7 @@ bool controller::on(const sig_ev::exit_reload&) { /** * Process eventqueue check event */ -bool controller::on(const sig_ev::check_state&) { +bool controller::on(const signals::eventqueue::check_state&) { for (const auto& block : m_modules) { for (const auto& module : block.second) { if (module->running()) { @@ -536,14 +536,14 @@ bool controller::on(const sig_ev::check_state&) { } } m_log.warn("No running modules..."); - on(sig_ev::exit_terminate{}); + on(signals::eventqueue::exit_terminate{}); return true; } /** * Process ui button press event */ -bool controller::on(const sig_ui::button_press& evt) { +bool controller::on(const signals::ui::button_press& evt) { string input{evt.cast()}; if (input.empty()) { @@ -558,7 +558,7 @@ bool controller::on(const sig_ui::button_press& evt) { /** * Process ipc action messages */ -bool controller::on(const sig_ipc::action& evt) { +bool controller::on(const signals::ipc::action& evt) { string action{evt.cast()}; if (action.empty()) { @@ -574,7 +574,7 @@ bool controller::on(const sig_ipc::action& evt) { /** * Process ipc command messages */ -bool controller::on(const sig_ipc::command& evt) { +bool controller::on(const signals::ipc::command& evt) { string command{evt.cast()}; if (command.empty()) { @@ -595,7 +595,7 @@ bool controller::on(const sig_ipc::command& evt) { /** * Process ipc hook messages */ -bool controller::on(const sig_ipc::hook& evt) { +bool controller::on(const signals::ipc::hook& evt) { string hook{evt.cast()}; for (const auto& block : m_modules) { diff --git a/src/components/ipc.cpp b/src/components/ipc.cpp index 9cd8b5df..51a151d1 100644 --- a/src/components/ipc.cpp +++ b/src/components/ipc.cpp @@ -11,8 +11,6 @@ POLYBAR_NS -namespace sig_ipc = signals::ipc; - /** * Create instance */ @@ -61,11 +59,11 @@ void ipc::receive_message() { string payload{string_util::trim(string{buffer}, '\n')}; if (payload.find(ipc_command::prefix) == 0) { - m_sig.emit(sig_ipc::command{payload.substr(strlen(ipc_command::prefix))}); + m_sig.emit(signals::ipc::command{payload.substr(strlen(ipc_command::prefix))}); } else if (payload.find(ipc_hook::prefix) == 0) { - m_sig.emit(sig_ipc::hook{payload.substr(strlen(ipc_hook::prefix))}); + m_sig.emit(signals::ipc::hook{payload.substr(strlen(ipc_hook::prefix))}); } else if (payload.find(ipc_action::prefix) == 0) { - m_sig.emit(sig_ipc::action{payload.substr(strlen(ipc_action::prefix))}); + m_sig.emit(signals::ipc::action{payload.substr(strlen(ipc_action::prefix))}); } else if (!payload.empty()) { m_log.warn("Received unknown ipc message: (payload=%s)", payload); } diff --git a/src/utils/env.cpp b/src/utils/env.cpp index 4a4c10fc..d4eb5b7d 100644 --- a/src/utils/env.cpp +++ b/src/utils/env.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include