Repository navigation
win32: fix cursor coordinates when starting window dragging - #4765
Open
smittie2000 wants to merge 2 commits into
Open
smittie2000 wants to merge 2 commits into
smittie2000 wants to merge 2 commits into
Conversation
Contributor
|
Looks sensible. |
Author
|
I did not think of that. Let me know if i change it. Something in the lines of let position = unsafe { mem::transmute::<POINTS, u32>(points) } as LPARAM; |
smittie2000
force-pushed
the
codex/fix-win32-drag-coordinates
branch
from
October 22, 2026 10:29
3d330f0 to
1449a93
Compare
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.
Microsoft describes
lParamforWM_NCLBUTTONDOWNas aPOINTSstructure,so using
POINTSto hold the coordinates makes sense. The issue is theconversion at the call site:
&points as *const _ as LPARAMpasses thestructure's memory address rather than its coordinate values.
The documentation's
GET_X_LPARAMandGET_Y_LPARAMexamples clarify thatWindows reads the coordinates from the bits of
lParamitself. Keeping aPOINTSvariable would also work if its fields were packed intoLPARAM;this change packs the coordinates directly, so that intermediate structure
is no longer needed. It fixes the shared path used by
drag_windowanddrag_resize_window.The new line is:
Windows expects two signed 16-bit coordinates packed into one value:
as u16keeps each coordinate's lowest 16 bits, preserving negativecoordinates:
-1becomes0xffff, which Windows decodes back to-1.u32::from(...)widens each value with zeros in the upper bits, leavingroom for both coordinates without sign extension overwriting either word.
<< 16moves y into the upper word.|combines the two words without overlap. The result is cast toLPARAM.See Microsoft's WM_NCLBUTTONDOWN documentation
for the coordinate layout and signed decoding.
Validation on Windows 10 x64:
the fix and pass afterward.
documentation build pass.
git diff --checkpasses.
These checks verify the message payload, not a drag-latency improvement.