@@ -74,6 +74,7 @@ public final class Cursor extends Resource {
7474 private final ImageData mask ;
7575 private final int hotspotX ;
7676 private final int hotspotY ;
77+ private Integer style ;
7778/**
7879 * Prevents uninitialized instances from being created outside the package.
7980 */
@@ -135,6 +136,7 @@ public final class Cursor extends Resource {
135136 */
136137public Cursor (Device device , int style ) {
137138 this (device );
139+ this .style = style ;
138140 this .handle = setupCursorFromStyle (style );
139141 init ();
140142}
@@ -430,10 +432,11 @@ public static Long win32_getHandle (Cursor cursor, int zoom) {
430432 if (cursor .zoomLevelToHandle .get (zoom ) != null ) {
431433 return cursor .zoomLevelToHandle .get (zoom );
432434 }
433-
434- if (cursor .source == null ) {
435- cursor .setHandleForZoomLevel (cursor .handle , zoom );
436- } else {
435+ if (cursor .style != null ) {
436+ // we don't need to pass zoom in this case. LoadCursor will always return scaled cursor even though handle value will be same for all zoom levels.
437+ long handle = setupCursorFromStyle (cursor .style );
438+ cursor .setHandleForZoomLevel (handle , zoom );
439+ } else {
437440 ImageData source ;
438441 if (cursor .imageDataProvider != null ) {
439442 Image tempImage = new Image (cursor .getDevice (), cursor .imageDataProvider );
@@ -444,12 +447,12 @@ public static Long win32_getHandle (Cursor cursor, int zoom) {
444447 source = DPIUtil .scaleImageData (cursor .device , cursor .source , zoom , DEFAULT_ZOOM );
445448 }
446449 if (cursor .isIcon ) {
447- Cursor newCursor = new Cursor (cursor .device , source , Win32DPIUtils .pointToPixel (cursor .hotspotX , zoom ), Win32DPIUtils .pointToPixel (cursor .hotspotY , zoom ));
448- cursor .setHandleForZoomLevel (newCursor . handle , zoom );
450+ long handle = setupCursorFromImageData (cursor .getDevice () , source , Win32DPIUtils .pointToPixel (cursor .hotspotX , zoom ), Win32DPIUtils .pointToPixel (cursor .hotspotY , zoom ));
451+ cursor .setHandleForZoomLevel (handle , zoom );
449452 } else {
450- ImageData mask = DPIUtil .scaleImageData (cursor .device , cursor .mask , zoom , DEFAULT_ZOOM );
451- Cursor newCursor = new Cursor ( cursor . device , source , mask , Win32DPIUtils .pointToPixel (cursor .hotspotX , zoom ), Win32DPIUtils .pointToPixel (cursor .hotspotY , zoom ));
452- cursor .setHandleForZoomLevel (newCursor . handle , zoom );
453+ ImageData mask = DPIUtil .scaleImageData (cursor .getDevice () , cursor .mask , zoom , DEFAULT_ZOOM );
454+ long handle = setupCursorFromImageData ( source , mask , Win32DPIUtils .pointToPixel (cursor .hotspotX , zoom ), Win32DPIUtils .pointToPixel (cursor .hotspotY , zoom ));
455+ cursor .setHandleForZoomLevel (handle , zoom );
453456 }
454457 }
455458 return cursor .zoomLevelToHandle .get (zoom );
0 commit comments