Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide tooltip on window leave event #5309

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

Nerixyz
Copy link
Contributor

@Nerixyz Nerixyz commented Apr 8, 2024

Disclaimer: This solution is really hacky.

I think #5308 is a bug in Qt. I'm not entirely sure what the root cause is (possibly some bad order of queued events). The bug happens when quickly moving the mouse and right-clicking on the split header. When the QMenu is shown, focus is transferred, eventually causing a leave-event to be sent to the focused window. In our case, it's a QWidgetWindow. Usually, the widget to receive the leave-event (and propagate it upwards) is set to qt_last_mouse_receiver - e.g. the QLabel showing the channel info. However, when things go wrong, qt_last_mouse_receiver is set to the newly created QMenu before the leave-event is delivered. But wait, doesn't sendMouseEvent get the last mouse receiver, so it could deliver the leave-event? Yea, but it only does so if the mouse is over the QMenu, which it isn't.

So, what do we do? If the receiver isn't set to qt_last_mouse_receiver, it's set to the window-widget, m_widget, which is our BaseWindow. To prevent the tooltip getting stuck, we use the window's leave-event to hide it. This isn't ideal, but it works.

If you test a lot, you might notice similar effects in other parts. For example, buttons sometimes get stuck in a hovered state when moving the mouse quickly and clicking. I suspect the same (or a really similar) cause. This is a pain to debug - it would be nice if there was an easier way to reproduce.

Fixes #5308.

@sando
Copy link
Contributor

sando commented Apr 9, 2024

Confirmed this fixes the issue, thanks!

Copy link
Member

@pajlada pajlada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@pajlada pajlada merged commit dd62707 into Chatterino:master Apr 9, 2024
17 checks passed
@Nerixyz Nerixyz deleted the fix/yet-another-tooltip-bug branch April 9, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Split header tooltip sometimes gets stuck
3 participants