fix: avoid promoting child widgets to child windows #5161
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.
The issue this fixes is at least similar to #5006, but since there aren't any reproduction steps, I don't know for sure if it's the same.
I could reproduce the issue by enabling the Always on top setting, restarting Chatterino and then opening the settings. Afterward, the main window was immovable.
The underlying issue with
winId
:Even though
QWidget::winId()
isconst
, it can create windows. In our case, it can promote child widgets to native windows. Visually, there's no change, but these child windows all handle events on their own and on Windows, the parent only gets info about this throughWM_PARENTNOTIFY
- thus the non-client events aren't sent, and the window appears to be immovable.To prevent this, we set
AA_DontCreateNativeWidgetSiblings
. Additionally, we check if the window has been created yet when getting the window-id, if we don't know the HWND from some native message, as calling the function will create a window-id if none has been created yet. For theisTopMost
setting, we wait until the window has a window-id and apply the setting there.I'm inclined to say #4994 didn't cause this (hence, I don't know for sure if it fixes the mentioned issue).