JDK-8158776 : [hidpi] The hotspot of the custom cursor isn't correct
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u73,9
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: other
  • CPU: x86
  • Submitted: 2016-02-18
  • Updated: 2020-03-01
  • Resolved: 2020-03-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
I use a custom cursor in my application with a width of 30 and height of 30.

If I increase my DPI to 200% than my screen resolution is 192 dpi instead of 96. 

Java scales the image, but the hotspot will not be scaled.

*) Hotspot defined at the left-bottom corner
*) In case of 100% -> it's correct
*) In case of 200% -> it looks like the hotspot was defined at the left-center



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.) Create an application which uses a custom cursor
2.) Define the hotspot at the left-bottom corner
3) Increase the display resolution from 100% to Extra Large -200% 
-> sign out before you test it again. 
4) the hotspot is not at the left-bottom corner but at the left-center 

myComponent.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(image, 
		    new Point(0,30), "mycursor"))


REPRODUCIBILITY :
This bug can be reproduced always.


Comments
The current implementation works according to the specification. - The image passed to the createCustomCursor() is the image to display when the cursor is activated. If an image is used whose dimensions don't match a supported size (as returned by getBestCursorSize), the Toolkit implementation will attempt to resize the image to a supported size. - The hotSpot passed to the createCustomCursor() is the X and Y of the large cursor's hot spot; the hotSpot values must be less than the Dimension returned by getBestCursorSize. The specification does not say that the hotspot should be scaled in the same way as an image. If that scale will be implemented then the next use case if used by the application will be broken: - The image 16x16 - The BestCursorSize 32x32 - The hotspot 16x16 If we will scale the hotspot by the x2(by the same scale as an image) then an application will get IndexOutOfBoundsException("invalid hotSpot"). This also confirmed by a number of TCK tests. As a solution to the current CR, the application itself should scale hotspot according to a result of getBestCursorSize. Specifications: https://docs.oracle.com/javase/8/docs/api/java/awt/Toolkit.html#createCustomCursor-java.awt.Image-java.awt.Point-java.lang.String- https://docs.oracle.com/javase/8/docs/api/java/awt/Toolkit.html#getBestCursorSize-int-int-
01-03-2020

Need to clarify what units should be used when we provide and use the "size", "bestCursorSIze" "hotspot" etc..., units or pixels?
14-02-2020

Could be related to JDK-8158205
16-06-2016