From ba0a156bbe96d0eb03d2c4f186fb795cb4e81ef2 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Sat, 30 May 2020 22:45:36 +0200 Subject: [PATCH] refactor: Deprecate throttle-input-for setting (#2117) If an input is enqueued as a response to an input, the new input will be swallowed because it will likely be enqueued less than 30ms after the original event. This is not something that is an issue right now but it is required to finish #1907 where, in order to close the menu after a click, the menu module gets an exec action that closes the menu and adds a command to the event queue. The setting also isn't too useful since it will just break polybar input handling if inputs arrive too fast instead of (possibly) slowing down the bar. --- include/components/controller.hpp | 10 ---------- src/components/controller.cpp | 9 +++++---- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/include/components/controller.hpp b/include/components/controller.hpp index cf21b871..6b07f527 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -131,16 +131,6 @@ class controller */ std::chrono::milliseconds m_swallow_update{10}; - /** - * \brief Time to throttle input events - */ - std::chrono::milliseconds m_swallow_input{30}; - - /** - * \brief Time of last handled input event - */ - std::chrono::time_point m_lastinput; - /** * \brief Input data */ diff --git a/src/components/controller.cpp b/src/components/controller.cpp index 5d2a86b9..8560d00c 100644 --- a/src/components/controller.cpp +++ b/src/components/controller.cpp @@ -58,7 +58,11 @@ controller::controller(connection& conn, signal_emitter& emitter, const logger& , m_bar(forward(bar)) , m_ipc(forward(ipc)) , m_confwatch(forward(confwatch)) { - m_swallow_input = m_conf.get("settings", "throttle-input-for", m_swallow_input); + + if (m_conf.has("settings", "throttle-input-for")) { + m_log.warn("The config parameter 'settings.throttle-input-for' is deprecated, it will be removed in the future. Please remove it from your config"); + } + m_swallow_limit = m_conf.deprecated("settings", "eventqueue-swallow", "throttle-output", m_swallow_limit); m_swallow_update = m_conf.deprecated("settings", "eventqueue-swallow-time", "throttle-output-for", m_swallow_update); @@ -201,8 +205,6 @@ bool controller::enqueue(event&& evt) { bool controller::enqueue(string&& input_data) { if (!m_inputdata.empty()) { m_log.trace("controller: Swallowing input event (pending data)"); - } else if (chrono::system_clock::now() - m_swallow_input < m_lastinput) { - m_log.trace("controller: Swallowing input event (throttled)"); } else { m_inputdata = forward(input_data); return enqueue(make_input_evt()); @@ -390,7 +392,6 @@ void controller::process_eventqueue() { void controller::process_inputdata() { if (!m_inputdata.empty()) { string cmd = m_inputdata; - m_lastinput = chrono::time_point_cast(chrono::system_clock::now()); m_inputdata.clear(); for (auto&& handler : m_inputhandlers) {