From 4efa1231835f87b55852cdf9e27b96d0cdb3d60c Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Fri, 2 Aug 2024 22:30:56 -0500 Subject: [PATCH 1/4] group: clang-tidy --- include/group.hpp | 2 +- src/group.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/group.hpp b/include/group.hpp index b10402c6..5ce331a8 100644 --- a/include/group.hpp +++ b/include/group.hpp @@ -12,7 +12,7 @@ namespace waybar { class Group : public AModule { public: Group(const std::string &, const std::string &, const Json::Value &, bool); - virtual ~Group() = default; + ~Group() override = default; auto update() -> void override; operator Gtk::Widget &() override; diff --git a/src/group.cpp b/src/group.cpp index deeecc75..2660868a 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -9,7 +9,7 @@ namespace waybar { -const Gtk::RevealerTransitionType getPreferredTransitionType(bool is_vertical) { +Gtk::RevealerTransitionType getPreferredTransitionType(bool is_vertical) { /* The transition direction of a drawer is not actually determined by the transition type, * but rather by the order of 'box' and 'revealer_box': * 'REVEALER_TRANSITION_TYPE_SLIDE_LEFT' and 'REVEALER_TRANSITION_TYPE_SLIDE_RIGHT' @@ -112,7 +112,7 @@ bool Group::handleToggle(GdkEventButton* const& e) { if (!click_to_reveal || e->button != 1) { return false; } - if (box.get_state_flags() & Gtk::StateFlags::STATE_FLAG_PRELIGHT) { + if ((box.get_state_flags() & Gtk::StateFlags::STATE_FLAG_PRELIGHT) != 0U) { hide_group(); } else { show_group(); From 3ae81d62bc300ece26c23e4f01c44180d6cc3edc Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Fri, 2 Aug 2024 22:32:22 -0500 Subject: [PATCH 2/4] group: fix hover regression We aren't including the hover detection on the revealer, so when the animation fires we fire the leave event which starts an infinite loop of enter/leave while we watch boxes move back and forth. --- include/group.hpp | 1 + src/group.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/group.hpp b/include/group.hpp index 5ce331a8..f5c6864b 100644 --- a/include/group.hpp +++ b/include/group.hpp @@ -30,6 +30,7 @@ class Group : public AModule { bool handleMouseEnter(GdkEventCrossing *const &ev) override; bool handleMouseLeave(GdkEventCrossing *const &ev) override; bool handleToggle(GdkEventButton *const &ev) override; + void addHoverHandlerTo(Gtk::Widget &widget); void show_group(); void hide_group(); }; diff --git a/src/group.cpp b/src/group.cpp index 2660868a..9b7ac2d5 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -81,9 +81,16 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value& } } + addHoverHandlerTo(revealer); event_box_.add(box); } +void Group::addHoverHandlerTo(Gtk::Widget& widget) { + widget.add_events(Gdk::EventMask::ENTER_NOTIFY_MASK | Gdk::EventMask::LEAVE_NOTIFY_MASK); + widget.signal_enter_notify_event().connect(sigc::mem_fun(*this, &Group::handleMouseEnter)); + widget.signal_leave_notify_event().connect(sigc::mem_fun(*this, &Group::handleMouseLeave)); +} + void Group::show_group() { box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT); revealer.set_reveal_child(true); From 05d69ae82244cb28d4ce22009dc2bc486d278574 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Fri, 2 Aug 2024 22:37:06 -0500 Subject: [PATCH 3/4] src/util/css_reload_helper: clang-format --- src/util/css_reload_helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/css_reload_helper.cpp b/src/util/css_reload_helper.cpp index e440c3c1..274bdeed 100644 --- a/src/util/css_reload_helper.cpp +++ b/src/util/css_reload_helper.cpp @@ -44,7 +44,7 @@ std::string waybar::CssReloadHelper::findPath(const std::string& filename) { // File monitor does not work with symlinks, so resolve them std::string original = result; - while(std::filesystem::is_symlink(result)) { + while (std::filesystem::is_symlink(result)) { result = std::filesystem::read_symlink(result); // prevent infinite cycle From 17f07b24522da93da28f3e9083d25cd7126489cf Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Fri, 2 Aug 2024 23:37:52 -0500 Subject: [PATCH 4/4] group: proper fix of enter/leave Ignore mouse leave event when we are still within the parent element --- include/group.hpp | 1 - src/group.cpp | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/include/group.hpp b/include/group.hpp index f5c6864b..5ce331a8 100644 --- a/include/group.hpp +++ b/include/group.hpp @@ -30,7 +30,6 @@ class Group : public AModule { bool handleMouseEnter(GdkEventCrossing *const &ev) override; bool handleMouseLeave(GdkEventCrossing *const &ev) override; bool handleToggle(GdkEventButton *const &ev) override; - void addHoverHandlerTo(Gtk::Widget &widget); void show_group(); void hide_group(); }; diff --git a/src/group.cpp b/src/group.cpp index 9b7ac2d5..50841efd 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -81,16 +81,9 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value& } } - addHoverHandlerTo(revealer); event_box_.add(box); } -void Group::addHoverHandlerTo(Gtk::Widget& widget) { - widget.add_events(Gdk::EventMask::ENTER_NOTIFY_MASK | Gdk::EventMask::LEAVE_NOTIFY_MASK); - widget.signal_enter_notify_event().connect(sigc::mem_fun(*this, &Group::handleMouseEnter)); - widget.signal_leave_notify_event().connect(sigc::mem_fun(*this, &Group::handleMouseLeave)); -} - void Group::show_group() { box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT); revealer.set_reveal_child(true); @@ -109,7 +102,7 @@ bool Group::handleMouseEnter(GdkEventCrossing* const& e) { } bool Group::handleMouseLeave(GdkEventCrossing* const& e) { - if (!click_to_reveal) { + if (!click_to_reveal && e->detail != GDK_NOTIFY_INFERIOR) { hide_group(); } return false;