fix: By-pass double click timers if no handlers are defined

Fixes #338
This commit is contained in:
Michael Carlberg 2017-01-15 02:00:33 +01:00
parent 084ff6d455
commit 40d482d039
3 changed files with 22 additions and 1 deletions

View File

@ -79,6 +79,7 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
string m_lastinput{};
std::mutex m_mutex{};
std::atomic<bool> m_dblclicks{false};
mousebtn m_buttonpress_btn{mousebtn::NONE};
int16_t m_buttonpress_pos{0};

View File

@ -355,6 +355,21 @@ void bar::parse(string&& data, bool force) {
}
m_renderer->end();
const auto check_dblclicks = [&]() -> bool {
for (auto&& action : m_renderer->get_actions()) {
if (static_cast<uint8_t>(action.button) >= static_cast<uint8_t>(mousebtn::DOUBLE_LEFT)) {
return true;
}
}
for (auto&& action : m_opts.actions) {
if (static_cast<uint8_t>(action.button) >= static_cast<uint8_t>(mousebtn::DOUBLE_LEFT)) {
return true;
}
}
return false;
};
m_dblclicks = check_dblclicks();
}
/**
@ -576,7 +591,11 @@ void bar::handle(const evt::button_press& evt) {
}
};
if (evt->detail == static_cast<uint8_t>(mousebtn::LEFT)) {
// If there are no double click handlers defined we can
// just by-pass the click timer handling
if (!m_dblclicks) {
deferred_fn(0);
} else if (evt->detail == static_cast<uint8_t>(mousebtn::LEFT)) {
check_double("buttonpress-left", mousebtn::DOUBLE_LEFT);
} else if (evt->detail == static_cast<uint8_t>(mousebtn::MIDDLE)) {
check_double("buttonpress-middle", mousebtn::DOUBLE_MIDDLE);

View File

@ -6,6 +6,7 @@
#include "events/signal_receiver.hpp"
#include "utils/factory.hpp"
#include "utils/file.hpp"
#include "x11/atoms.hpp"
#include "x11/connection.hpp"
#include "x11/draw.hpp"
#include "x11/extensions/all.hpp"