mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-25 04:32:10 +00:00
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:
parent
3c8c93d774
commit
35a6670868
2 changed files with 13 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue