Skip to content

fix(win32): preserve the window context across nested messages - #265

Open
JulienMaille wants to merge 1 commit into
stdware:mainfrom
JulienMaille:fix/win32-nested-nccalcsize
Open

JulienMaille wants to merge 1 commit into
stdware:mainfrom
JulienMaille:fix/win32-nested-nccalcsize

Conversation

@JulienMaille

Copy link
Copy Markdown
Contributor

Fixes #264.

QWKHookedWndProc() cleared WindowsNativeEventFilter::lastMessageContext on return. A nested synchronous dispatch cleared it for the outer call too, so a later WM_NCCALCSIZE failed the windowId() check from #263 and got Qt's default frame insets.

Replace the scope guard with QScopedValueRollback<Win32WindowContext *> so the previous context is restored on return. The native event filter still checks that the message belongs to the current context's window.

Verified with MSVC and Qt 6.8.1 Widgets on Windows Server 2025. With the nested WM_NULL probe, the client top moved from 201 to 231 with system borders and from 200 to 231 without them. With the fix, the rectangle is identical with and without the nested dispatch in both configurations. The filter recorded one nested delivery per test. Baseline: run. Independent verification: run. macOS and Linux are not built in this change.

This PR contains only commit 80564f0. The other Win32 fixes in the fork are separate changes.

This branch has not been deployed

No deployments
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.

Nested message dispatch clears the Win32 window context

1 participant