Merge pull request #5032 from yyyumeniku/master
hyprland/workspaces: add debounce timer to prevent workspace button f…
This commit is contained in:
@@ -220,6 +220,9 @@ class Workspaces : public AModule, public EventHandler {
|
||||
Gtk::Box m_box;
|
||||
sigc::connection m_scrollEventConnection_;
|
||||
IPC& m_ipc;
|
||||
|
||||
sigc::connection m_debounceTimer;
|
||||
bool m_updatePending = false;
|
||||
};
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
||||
@@ -343,6 +343,7 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value& c
|
||||
}
|
||||
|
||||
void Workspaces::onEvent(const std::string& ev) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
const auto separator = ev.find(">>");
|
||||
if (separator == std::string::npos) {
|
||||
@@ -381,8 +382,23 @@ void Workspaces::onEvent(const std::string& ev) {
|
||||
} else if (eventName == "configreloaded") {
|
||||
onConfigReloaded();
|
||||
}
|
||||
}
|
||||
|
||||
if (m_debounceTimer.connected()) {
|
||||
m_debounceTimer.disconnect();
|
||||
m_updatePending = false;
|
||||
}
|
||||
|
||||
m_updatePending = true;
|
||||
m_debounceTimer = Glib::signal_timeout().connect([this]() {
|
||||
if (!m_updatePending) return false;
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
if (m_updatePending) {
|
||||
dp.emit();
|
||||
m_updatePending = false;
|
||||
}
|
||||
return false;
|
||||
}, 7);
|
||||
}
|
||||
|
||||
void Workspaces::onWorkspaceActivated(std::string const& payload) {
|
||||
|
||||
Reference in New Issue
Block a user