fix: hide tooltip on window leave event #5309
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'tsendMouseEvent
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 ourBaseWindow
. 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.