1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-18 13:55:11 -05:00

Notification string to a queue of strings (#2517)

Fixes #2469

* made inputdata to queue<string>

* changed back to front

* fixed move semantics issue while popping queue

* Removed ide file

* commented test lines

* review changes

* review changes

* Update CHANGELOG.md

* Cleanup

Co-authored-by: patrick96 <p.ziegler96@gmail.com>
This commit is contained in:
Madhav Prabhu C M 2021-10-03 14:54:24 +05:30 committed by GitHub
parent 1a59599388
commit e5ab7e1c00
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 13 deletions

1
.gitignore vendored
View file

@ -6,5 +6,6 @@
*.swp *.swp
*.tmp *.tmp
.tags .tags
*.user
polybar-*.tar polybar-*.tar

View file

@ -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 - Clicks arriving in close succession, no longer get dropped. Before polybar
would drop any click that arrived within 5ms of the previous one. would drop any click that arrived within 5ms of the previous one.
- Increased the double click interval from 150ms to 400ms. - 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 ### Fixed
- `custom/script`: Concurrency issues with fast-updating tailed scripts. - `custom/script`: Concurrency issues with fast-updating tailed scripts.

View file

@ -2,6 +2,7 @@
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>
#include <queue>
#include "common.hpp" #include "common.hpp"
#include "components/eventloop.hpp" #include "components/eventloop.hpp"
@ -15,6 +16,8 @@
POLYBAR_NS POLYBAR_NS
using std::queue;
// fwd decl {{{ // fwd decl {{{
enum class alignment; enum class alignment;
@ -30,7 +33,6 @@ namespace modules {
} // namespace modules } // namespace modules
using module_t = shared_ptr<modules::module_interface>; using module_t = shared_ptr<modules::module_interface>;
using modulemap_t = std::map<alignment, vector<module_t>>; using modulemap_t = std::map<alignment, vector<module_t>>;
// }}} // }}}
class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, signals::eventqueue::exit_reload, class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, signals::eventqueue::exit_reload,
@ -83,9 +85,9 @@ class controller : public signal_receiver<SIGN_PRIORITY_CONTROLLER, signals::eve
bool reload; bool reload;
bool update; bool update;
bool force_update; bool force_update;
string inputdata; queue<string> 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<string>{}) {}
}; };
size_t setup_modules(alignment align); size_t setup_modules(alignment align);

View file

@ -128,13 +128,9 @@ bool controller::run(bool writeback, string snapshot_dst, bool confwatch) {
*/ */
void controller::trigger_action(string&& input_data) { void controller::trigger_action(string&& input_data) {
std::unique_lock<std::mutex> guard(m_notification_mutex); std::unique_lock<std::mutex> guard(m_notification_mutex);
m_log.trace("controller: Queueing input event '%s'", input_data);
if (m_notifications.inputdata.empty()) { m_notifications.inputdata.push(std::move(input_data));
m_notifications.inputdata = std::move(input_data); trigger_notification();
trigger_notification();
} else {
m_log.trace("controller: Swallowing input event (pending data)");
}
} }
void controller::trigger_quit(bool reload) { void controller::trigger_quit(bool reload) {
@ -215,8 +211,11 @@ void controller::notifier_handler() {
return; return;
} }
if (!data.inputdata.empty()) { while (!data.inputdata.empty()) {
process_inputdata(std::move(data.inputdata)); auto inputdata = data.inputdata.front();
data.inputdata.pop();
m_log.trace("controller: Dequeueing inputdata: '%s'", inputdata);
process_inputdata(std::move(inputdata));
} }
if (data.update) { 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()); m_log.err("controller: Error while forwarding input to shell -> %s", err.what());
} }
} }
/** /**
* Process eventqueue update event * Process eventqueue update event
*/ */