From ab7bc8de1c7319fa7398fcc448616a2bee075034 Mon Sep 17 00:00:00 2001 From: cebem1nt Date: Sat, 18 Apr 2026 13:34:29 -0300 Subject: [PATCH] feature: group - add reveal-delay config option for drawer --- include/group.hpp | 3 +++ src/group.cpp | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/group.hpp b/include/group.hpp index d5cbb289..c5faf7c3 100644 --- a/include/group.hpp +++ b/include/group.hpp @@ -10,6 +10,8 @@ namespace waybar { class Group : public AModule { + sigc::connection reveal_timeout_; + public: Group(const std::string&, const std::string&, const Json::Value&, bool); ~Group() override = default; @@ -26,6 +28,7 @@ class Group : public AModule { bool is_first_widget = true; bool is_drawer = false; bool click_to_reveal = false; + int reveal_delay = 0; std::string add_class_to_drawer_children; bool handleMouseEnter(GdkEventCrossing* const& ev) override; bool handleMouseLeave(GdkEventCrossing* const& ev) override; diff --git a/src/group.cpp b/src/group.cpp index acd7bd42..92734fc9 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -63,6 +63,7 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value& ? drawer_config["transition-left-to-right"].asBool() : true); click_to_reveal = drawer_config["click-to-reveal"].asBool(); + reveal_delay = drawer_config["reveal-delay"].asInt(); const bool start_expanded = (drawer_config["start-expanded"].isBool() ? drawer_config["start-expanded"].asBool() @@ -104,13 +105,27 @@ void Group::hide_group() { bool Group::handleMouseEnter(GdkEventCrossing* const& e) { if (!click_to_reveal) { - show_group(); + if (reveal_delay > 0) { + if (reveal_timeout_.connected()) { + reveal_timeout_.disconnect(); + } + + reveal_timeout_ = Glib::signal_timeout().connect( + [this]() { show_group(); return false; }, + reveal_delay); + } else { + show_group(); + } } return false; } bool Group::handleMouseLeave(GdkEventCrossing* const& e) { if (!click_to_reveal && e->detail != GDK_NOTIFY_INFERIOR) { + if (reveal_delay > 0 && reveal_timeout_.connected()) { + reveal_timeout_.disconnect(); + } + hide_group(); } return false;