fix: check if double click action associated (#2695)

When a module is clicked, only wait for the double click interval if a
double click action is associated with that module. Otherwise trigger
the click right away.

Fixes: #2663
This commit is contained in:
Mathis Weber
2022-04-25 03:59:40 -07:00
committed by GitHub
parent 4961a7dcfc
commit b5292791ef
3 changed files with 14 additions and 14 deletions

View File

@ -415,19 +415,12 @@ void bar::parse(string&& data, bool force) {
m_renderer->end();
const auto check_dblclicks = [&]() -> bool {
if (m_action_ctxt->has_double_click()) {
return true;
m_dblclicks.clear();
for (auto&& action : m_opts.actions) {
if (static_cast<int>(action.button) >= static_cast<int>(mousebtn::DOUBLE_LEFT)) {
m_dblclicks.insert(action.button);
}
for (auto&& action : m_opts.actions) {
if (static_cast<int>(action.button) >= static_cast<int>(mousebtn::DOUBLE_LEFT)) {
return true;
}
}
return false;
};
m_dblclicks = check_dblclicks();
}
}
/**
@ -818,9 +811,12 @@ void bar::handle(const evt::button_press& evt) {
}
};
mousebtn double_btn = mousebtn_get_double(btn);
bool has_dblclick = m_dblclicks.count(double_btn) || m_action_ctxt->has_action(double_btn, pos) != tags::NO_ACTION;
// If there are no double click handlers defined we can
// just by-pass the click timer handling
if (!m_dblclicks) {
if (!has_dblclick) {
trigger_click(btn, pos);
} else if (btn == mousebtn::LEFT) {
check_double(m_leftclick_timer, btn, pos);