diff --git a/.gitignore b/.gitignore index df580e2c..e25c24ce 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ *.swp *.tmp .tags +*.user polybar-*.tar diff --git a/CHANGELOG.md b/CHANGELOG.md index 04063b28..bc0b3589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -141,6 +141,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Clicks arriving in close succession, no longer get dropped. Before polybar would drop any click that arrived within 5ms of the previous one. - Increased the double click interval from 150ms to 400ms. +- Stop ignoring actions if they arrive while the previous one hasn't been processed yet. + ([`#2469`](https://github.com/polybar/polybar/issues/2469)) ### Fixed - `custom/script`: Concurrency issues with fast-updating tailed scripts. diff --git a/include/components/controller.hpp b/include/components/controller.hpp index 4d8555a3..080100f8 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -2,6 +2,7 @@ #include #include +#include #include "common.hpp" #include "components/eventloop.hpp" @@ -15,6 +16,8 @@ POLYBAR_NS +using std::queue; + // fwd decl {{{ enum class alignment; @@ -30,7 +33,6 @@ namespace modules { } // namespace modules using module_t = shared_ptr; using modulemap_t = std::map>; - // }}} class controller : public signal_receiver inputdata; - notifications_t() : quit(false), reload(false), update(false), force_update(false), inputdata(string{}) {} + notifications_t() : quit(false), reload(false), update(false), force_update(false), inputdata(queue{}) {} }; size_t setup_modules(alignment align); diff --git a/src/components/controller.cpp b/src/components/controller.cpp index 392daa4b..be7f3bc4 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -128,13 +128,9 @@ bool controller::run(bool writeback, string snapshot_dst, bool confwatch) { */ void controller::trigger_action(string&& input_data) { std::unique_lock guard(m_notification_mutex); - - if (m_notifications.inputdata.empty()) { - m_notifications.inputdata = std::move(input_data); - trigger_notification(); - } else { - m_log.trace("controller: Swallowing input event (pending data)"); - } + m_log.trace("controller: Queueing input event '%s'", input_data); + m_notifications.inputdata.push(std::move(input_data)); + trigger_notification(); } void controller::trigger_quit(bool reload) { @@ -215,8 +211,11 @@ void controller::notifier_handler() { return; } - if (!data.inputdata.empty()) { - process_inputdata(std::move(data.inputdata)); + while (!data.inputdata.empty()) { + auto inputdata = data.inputdata.front(); + data.inputdata.pop(); + m_log.trace("controller: Dequeueing inputdata: '%s'", inputdata); + process_inputdata(std::move(inputdata)); } if (data.update) { @@ -461,7 +460,6 @@ void controller::process_inputdata(string&& cmd) { m_log.err("controller: Error while forwarding input to shell -> %s", err.what()); } } - /** * Process eventqueue update event */