fix(eventloop): Acquire lock guard

This commit is contained in:
Michael Carlberg 2016-12-14 19:04:33 +01:00
parent e11798253a
commit 4c36d65cbe
3 changed files with 10 additions and 10 deletions

View File

@ -121,16 +121,16 @@ class eventloop : public signal_receiver<SIGN_PRIORITY_EVENTLOOP, process_quit,
*/
chrono::milliseconds m_swallow_input{30ms};
/**
* @brief Time of last handled input event
*/
chrono::time_point<chrono::system_clock, chrono::milliseconds> m_lastinput;
/**
* @brief Mutex used to guard input data
*/
std::mutex m_inputlock;
/**
* @brief Time of last handled input event
*/
chrono::time_point<chrono::system_clock, decltype(m_swallow_input)> m_lastinput;
/**
* @brief Input data
*/

View File

@ -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<string>(input_data);
m_inputdata = move(input_data);
return enqueue(make_input_evt());
}

View File

@ -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;
}