From 4c36d65cbefeb6aa4237bc47f9686c025a4ed2dd Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Wed, 14 Dec 2016 19:04:33 +0100 Subject: [PATCH] fix(eventloop): Acquire lock guard --- include/components/eventloop.hpp | 10 +++++----- src/components/eventloop.cpp | 6 +++--- src/modules/i3.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/components/eventloop.hpp b/include/components/eventloop.hpp index d3ff2804..f09a9d02 100644 --- a/include/components/eventloop.hpp +++ b/include/components/eventloop.hpp @@ -121,16 +121,16 @@ class eventloop : public signal_receiver m_lastinput; + /** * @brief Mutex used to guard input data */ std::mutex m_inputlock; - /** - * @brief Time of last handled input event - */ - chrono::time_point m_lastinput; - /** * @brief Input data */ diff --git a/src/components/eventloop.cpp b/src/components/eventloop.cpp index f05a8686..e460f2d0 100644 --- a/src/components/eventloop.cpp +++ b/src/components/eventloop.cpp @@ -124,7 +124,6 @@ bool eventloop::enqueue(event&& evt) { m_log.warn("Failed to enqueue event"); return false; } - return true; } @@ -132,7 +131,7 @@ bool eventloop::enqueue(event&& evt) { * Enqueue input data */ bool eventloop::enqueue(string&& input_data) { - if (m_inputlock.try_lock()) { + if (!m_inputlock.try_lock()) { return false; } @@ -146,7 +145,8 @@ bool eventloop::enqueue(string&& input_data) { return false; } - m_inputdata = forward(input_data); + m_inputdata = move(input_data); + return enqueue(make_input_evt()); } diff --git a/src/modules/i3.cpp b/src/modules/i3.cpp index 29657726..48b5050d 100644 --- a/src/modules/i3.cpp +++ b/src/modules/i3.cpp @@ -209,10 +209,10 @@ namespace modules { m_log.info("%s: Sending workspace focus command to ipc handler", name()); conn.send_command("workspace number " + workspace_num); } - } else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) { - scrolldir = m_revscroll ? "next" : "prev"; } else if (cmd.compare(0, strlen(EVENT_SCROLL_UP), EVENT_SCROLL_UP) == 0) { scrolldir = m_revscroll ? "prev" : "next"; + } else if (cmd.compare(0, strlen(EVENT_SCROLL_DOWN), EVENT_SCROLL_DOWN) == 0) { + scrolldir = m_revscroll ? "next" : "prev"; } else { return false; }