Fix issue with audio slider

Due to the fact, that we needed to manually propagate hover events from
the slider, two hover events are sent when coming from the side of the
slider. This we need to await BOTH close events until we can call the
leave function.
This commit is contained in:
scorpion-26 2023-02-22 17:20:30 +01:00
parent 3c8c93d774
commit 35a6670868
2 changed files with 13 additions and 2 deletions

View file

@ -204,15 +204,23 @@ void EventBox::Create()
auto enter = [](GtkWidget*, GdkEventCrossing*, gpointer data) -> gboolean
{
EventBox* box = (EventBox*)data;
if (box->m_HoverFn)
if (box->m_HoverFn && box->m_DiffHoverEvents <= 0)
{
box->m_HoverFn(*box, true);
box->m_DiffHoverEvents = 0;
}
box->m_DiffHoverEvents++;
return false;
};
auto leave = [](GtkWidget*, GdkEventCrossing*, void* data) -> gboolean
{
EventBox* box = (EventBox*)data;
if (box->m_HoverFn)
box->m_DiffHoverEvents--;
if (box->m_HoverFn && box->m_DiffHoverEvents <= 0)
{
box->m_HoverFn(*box, false);
box->m_DiffHoverEvents = 0;
}
return false;
};
// I am so done with the GTK docs. The docs clearly say GdkEventScroll and not GdkEventScroll*, but GdkEventScroll* is passed

View file

@ -205,6 +205,9 @@ public:
virtual void Create() override;
private:
// If two hover events are sent, it needs also two close events for a close.
// Somehow not doing that causes an issue.
int32_t m_DiffHoverEvents = 0;
std::function<void(EventBox&, bool)> m_HoverFn;
std::function<void(EventBox&, ScrollDirection)> m_ScrollFn;
};