From 2e231472159e2b2a5dfc2e4bed69855b88e8fab3 Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Thu, 17 Apr 2025 16:45:47 -0400 Subject: [PATCH] feat(group): add reveal-by-default option --- man/waybar.5.scd.in | 5 +++++ src/group.cpp | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/man/waybar.5.scd.in b/man/waybar.5.scd.in index 5bb62724..e817e26a 100644 --- a/man/waybar.5.scd.in +++ b/man/waybar.5.scd.in @@ -322,6 +322,11 @@ A group may hide all but one element, showing them only on mouse hover. In order Defines the direction of the transition animation. If true, the hidden elements will slide from left to right. If false, they will slide from right to left. When the bar is vertical, it reads as top-to-bottom. +*reveal-by-default*: ++ + typeof: bool ++ + default: false ++ + Whether the child should be revealed when Waybar starts up. This has to be used with click-to-reveal to take effect. + ``` "group/power": { "orientation": "inherit", diff --git a/src/group.cpp b/src/group.cpp index 50841efd..31d60285 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -62,13 +62,22 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value& const bool left_to_right = (drawer_config["transition-left-to-right"].isBool() ? drawer_config["transition-left-to-right"].asBool() : true); + const bool reveal_by_default = + (drawer_config["reveal-by-default"].isBool() ? drawer_config["reveal-by-default"].asBool() + : false); + click_to_reveal = drawer_config["click-to-reveal"].asBool(); auto transition_type = getPreferredTransitionType(vertical); revealer.set_transition_type(transition_type); revealer.set_transition_duration(transition_duration); - revealer.set_reveal_child(false); + if (click_to_reveal && reveal_by_default) { + box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT); + revealer.set_reveal_child(true); + } else { + revealer.set_reveal_child(false); + } revealer.get_style_context()->add_class("drawer");