Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SetCursorPos and ClipCursor ignoring DPI awareness #1394

Merged
merged 2 commits into from
Dec 5, 2021

Conversation

alvinhochun
Copy link
Contributor

@alvinhochun alvinhochun commented Nov 22, 2021

This fixes the issue of SetCursorPos coordinates being scaled incorrectly when high-DPI display scaling is active. (#1369)

The DPI_AWARENESS_CONTEXT of the calling thread is passed to GuiServer, which is applied there before calling the actual WinAPI. The original DPI_AWARENESS_CONTEXT of the GuiServer thread is then restored immediately to prevent affecting other functions.

The same fix has been applied to ClipCursor, but I do not have a way to test it. SendInput doesn't seem to be affect by the looks of it. I have not checked the other APIs.

@isaak654 isaak654 linked an issue Nov 22, 2021 that may be closed by this pull request
@alvinhochun alvinhochun marked this pull request as draft November 22, 2021 12:25
@alvinhochun
Copy link
Contributor Author

Okay, I fixed these APIs for 32-bit processes, also verified with a simple WinForms program that ClipCursor was broken and fixed by this change.

@alvinhochun alvinhochun marked this pull request as ready for review November 22, 2021 13:10
@isaak654 isaak654 force-pushed the master branch 3 times, most recently from 600c1b2 to b2bc78e Compare December 3, 2021 21:50
@isaak654 isaak654 merged commit dcab315 into sandboxie-plus:master Dec 5, 2021
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.

SetCursorPos sets wrong coordinates with high-DPI scaling screens
2 participants