Repository navigation
win32: fix drag_window and drag_resize_window - #4825
Open
smittie2000 wants to merge 4 commits into
Open
smittie2000 wants to merge 4 commits into
smittie2000 wants to merge 4 commits into
Conversation
`dragging` was only cleared on `WM_EXITSIZEMOVE`. When Windows declined to start the modal move/size loop, such as when resizing a maximized window, that message never arrived and every later `drag_window` and `drag_resize_window` call returned early. `DefWindowProcW` only returns from `WM_NCLBUTTONDOWN` once the loop has ended or was never started, so clear the flag after it returns. Fixes rust-windowing#4821. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
smittie2000
force-pushed
the
smittie2000/fix-win32-stuck-dragging
branch
from
November 8, 2026 08:05
ea70141 to
ced83d2
Compare
If `PostMessageW` fails, for example because the message queue is full, no `WM_NCLBUTTONDOWN` arrives and nothing clears `dragging`, so later drags would be ignored. Log a warning and clear the flag instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #4821. Supersedes #4765, whose commit is included here unchanged.
This fixes two bugs in how
Window::drag_windowandWindow::drag_resize_windowstart a native move/size on Windows. They are in the samePostMessageWcall, so they are fixed together.Drags stop working after one that Windows did not perform (#4821)
handle_os_draggingsetsWindowState::draggingand returns early while it is set. The flag was only cleared onWM_EXITSIZEMOVE. When Windows declines to start the modal move/size loop, for example when resizing a maximized window, that message never arrives, so the flag stays set and every later drag call silently does nothing. This matches the report's observation that dragging the native title bar un-sticks it, since a real drag sendsWM_EXITSIZEMOVE.WM_NCLBUTTONDOWN,DefWindowProcWruns the modal loop and only returns once it has ended or was never started. It is now called inline and the flag is cleared after it returns, mirroring the existingWM_PAINTarm. The state lock is taken only after the call, because the modal loop re-enters the window procedure. In the normal caseWM_EXITSIZEMOVEhas already cleared the flag and posted theWM_LBUTTONUP, so the extra clear has no effect. NoWM_LBUTTONUPis posted when no loop ran, because the real one was not swallowed.PostMessageWitself fails (for example, the message queue is full), the message never arrives either, so that now logs a warning and clears the flag.Wrong cursor coordinates in
lParamThe message was posted with
&points as *const _ as LPARAM, which passes the address of aPOINTSstruct rather than the coordinates. Windows reads them from the bits oflParamitself: low word x, high word y, each a signed 16-bit value as decoded byGET_X_LPARAM/GET_Y_LPARAM(WM_NCLBUTTONDOWN). The cursor position is now packed intolParamdirectly. Each coordinate is truncated tou16first, so negative positions on monitors left of or above the primary one survive the round trip.Testing
On Windows with the
applicationexample, including on a secondary monitor at negative coordinates:v0.30.xhas both bugs, and #4821 was reported on 0.30.13. I'm happy to open a backport if that's wanted.🤖 Generated with Claude Code