From 39c12edc8a356339a9e3e25121515e13f297396e Mon Sep 17 00:00:00 2001 From: NBonaparte Date: Fri, 23 Mar 2018 23:59:24 -0700 Subject: [PATCH] fix(cursor): add lock to motion handler --- src/components/bar.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/bar.cpp b/src/components/bar.cpp index cb42ebd4..b5e6a030 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -610,6 +610,12 @@ void bar::handle(const evt::leave_notify&) { * Used to change the cursor depending on the module */ void bar::handle(const evt::motion_notify& evt) { + if (!m_mutex.try_lock()) { + return; + } + + std::lock_guard guard(m_mutex, std::adopt_lock); + m_log.trace("bar: Detected motion: %i at pos(%i, %i)", evt->detail, evt->event_x, evt->event_y); #if WITH_XCURSOR m_motion_pos = evt->event_x; @@ -691,7 +697,7 @@ void bar::handle(const evt::button_press& evt) { const auto deferred_fn = [&](size_t) { /* * Iterate over all defined actions in reverse order until matching action is found - * To properly handle nested actions we iterate in reverse because nested actions are added later than their + * To properly handle nested actions we iterate in reverse because nested actions are added later than their * surrounding action block */ auto actions = m_renderer->actions();