group: proper fix of enter/leave

Ignore mouse leave event when we are still within the parent element
This commit is contained in:
Austin Horstman 2024-08-02 23:37:52 -05:00
parent 05d69ae822
commit 17f07b2452
No known key found for this signature in database
2 changed files with 1 additions and 9 deletions

View File

@ -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();
};

View File

@ -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;