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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 deletions

View File

@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `custom/text`: Loads the `format` setting, which supports the `<label>` tag, if the deprecated `content` is not defined ([`#1331`](https://github.com/polybar/polybar/issues/1331), [`#2673`](https://github.com/polybar/polybar/pull/2673), [`#2676`](https://github.com/polybar/polybar/pull/2676))
- Added experimental support for positioning the tray like a module
### Fixed
- Waiting for double click interval on modules that don't have a double click action ([`#2663`](https://github.com/polybar/polybar/issues/2663), [`#2695`](https://github.com/polybar/polybar/pull/2695))
## [3.6.2] - 2022-04-03
### Fixed
- `format-offset` being ignored ([`#2643`](https://github.com/polybar/polybar/pull/2643))

View File

@ -1,6 +1,7 @@
#pragma once
#include <cstdlib>
#include <set>
#include "common.hpp"
#include "components/eventloop.hpp"
@ -104,7 +105,7 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
string m_cursor{};
string m_lastinput{};
bool m_dblclicks{false};
std::set<mousebtn> m_dblclicks;
eventloop::TimerHandle& m_leftclick_timer{m_loop.handle<eventloop::TimerHandle>()};
eventloop::TimerHandle& m_middleclick_timer{m_loop.handle<eventloop::TimerHandle>()};

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);