Merge pull request #5032 from yyyumeniku/master

hyprland/workspaces: add debounce timer to prevent workspace button f…
This commit is contained in:
Alexis Rouillard
2026-07-04 00:42:04 +02:00
committed by GitHub
2 changed files with 56 additions and 37 deletions
+3
View File
@@ -220,6 +220,9 @@ class Workspaces : public AModule, public EventHandler {
Gtk::Box m_box; Gtk::Box m_box;
sigc::connection m_scrollEventConnection_; sigc::connection m_scrollEventConnection_;
IPC& m_ipc; IPC& m_ipc;
sigc::connection m_debounceTimer;
bool m_updatePending = false;
}; };
} // namespace waybar::modules::hyprland } // namespace waybar::modules::hyprland
+16
View File
@@ -343,6 +343,7 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value& c
} }
void Workspaces::onEvent(const std::string& ev) { void Workspaces::onEvent(const std::string& ev) {
{
std::lock_guard<std::mutex> lock(m_mutex); std::lock_guard<std::mutex> lock(m_mutex);
const auto separator = ev.find(">>"); const auto separator = ev.find(">>");
if (separator == std::string::npos) { if (separator == std::string::npos) {
@@ -381,8 +382,23 @@ void Workspaces::onEvent(const std::string& ev) {
} else if (eventName == "configreloaded") { } else if (eventName == "configreloaded") {
onConfigReloaded(); 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(); dp.emit();
m_updatePending = false;
}
return false;
}, 7);
} }
void Workspaces::onWorkspaceActivated(std::string const& payload) { void Workspaces::onWorkspaceActivated(std::string const& payload) {