Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
17 changes: 16 additions & 1 deletion src/group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
Expand Down
Loading