mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 11:12:49 +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
|
auto enter = [](GtkWidget*, GdkEventCrossing*, gpointer data) -> gboolean
|
||||||
{
|
{
|
||||||
EventBox* box = (EventBox*)data;
|
EventBox* box = (EventBox*)data;
|
||||||
if (box->m_HoverFn)
|
if (box->m_HoverFn && box->m_DiffHoverEvents <= 0)
|
||||||
|
{
|
||||||
box->m_HoverFn(*box, true);
|
box->m_HoverFn(*box, true);
|
||||||
|
box->m_DiffHoverEvents = 0;
|
||||||
|
}
|
||||||
|
box->m_DiffHoverEvents++;
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
auto leave = [](GtkWidget*, GdkEventCrossing*, void* data) -> gboolean
|
auto leave = [](GtkWidget*, GdkEventCrossing*, void* data) -> gboolean
|
||||||
{
|
{
|
||||||
EventBox* box = (EventBox*)data;
|
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_HoverFn(*box, false);
|
||||||
|
box->m_DiffHoverEvents = 0;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
// I am so done with the GTK docs. The docs clearly say GdkEventScroll and not GdkEventScroll*, but GdkEventScroll* is passed
|
// 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;
|
virtual void Create() override;
|
||||||
|
|
||||||
private:
|
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&, bool)> m_HoverFn;
|
||||||
std::function<void(EventBox&, ScrollDirection)> m_ScrollFn;
|
std::function<void(EventBox&, ScrollDirection)> m_ScrollFn;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue