-
Notifications
You must be signed in to change notification settings - Fork 187
Fix incorrect cursor scaling by using autoscale zoom #2322
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
Conversation
4505f42 to
fbf1ddb
Compare
amartya4256
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested it for 175, 100 and 125% on both master and this branch.
My finding:
- On master the cursor takes the size of the native zoom.
- With this PR, the cursor is consistent with the zoom (device zoom/autoscaledZoom/specific to property, e.g.: quarter, half, etc)
Hence, approving it.
fedejeanne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks fine, I'm just confused about which issue does this PR solve (and how to test it). Is it #2308 ?
The screenshots you provided look similar to the ones in the issue but I don't see the "cursor" in them (the red square).
I see that this is documented in our internal issue (vi-eclipse/Eclipse-Platform#357). You just need to adapt the text of the commit and this PR's description to say that if fixes #2308.
Scratch that, I see now that they are GIFs and they ran only once so I missed the red square. It's there though 👍 |
Previously, custom cursors were scaled using the raw device zoom (getNativeZoom), which could result in mismatched sizes on high-DPI displays. This change replaces it with DPIUtil.getZoomForAutoscaleProperty to align cursor scaling with the rest of the UI. Fixes eclipse-platform#2308
|
The API check failure is unrelated. |
🐞 Problem Description
In SWT, custom cursors were being created with incorrect sizes on high-DPI displays. The root cause was this line:
The method
Cursor.win32_getHandle(...)usedgetNativeZoom()to determine the scale at which the cursor image should be rendered.However,
getNativeZoom()only reflects the raw device DPI scaling (e.g., 125%, 150%), and does not account for SWT’s autoscale policy (controlled via theswt.autoScaleproperty).This leads to inconsistencies:
✅ The Fix
To align cursor scaling with the rest of the SWT UI, the cursor zoom should be computed using the same logic that SWT uses for autoscaling across the toolkit.
Replace:
With:
This uses:
DPIUtil.getZoomForAutoscaleProperty(...), which applies the logic fromswt.autoScale(e.g., rounding zoom levels up to the nearest 100%)Various Cases with Snippets
- autoScale=1000
- autoScale=quarter, zoom = 175%
- autoScale=int200, zoom = 175%