|
19 | 19 | import org.eclipse.swt.*;
|
20 | 20 | import org.eclipse.swt.internal.*;
|
21 | 21 | import org.eclipse.swt.internal.win32.*;
|
| 22 | +import org.eclipse.swt.internal.win32.version.*; |
22 | 23 |
|
23 | 24 | /**
|
24 | 25 | * Instances of this class manage operating system resources that
|
@@ -349,6 +350,39 @@ private void setHandleForZoomLevel(CursorHandle handle, Integer zoom) {
|
349 | 350 | }
|
350 | 351 | }
|
351 | 352 |
|
| 353 | +/** |
| 354 | + * Retrieves the scaling factor of the mouse pointer size as set in Windows |
| 355 | + * 10/11 "Settings > Accessibility > Mouse pointer and touch > Size". |
| 356 | + * <p> |
| 357 | + * This method reads the "CursorBaseSize" registry value under |
| 358 | + * {@code HKEY_CURRENT_USER\Control Panel\Cursors}. If this registry value |
| 359 | + * exists (introduced in Windows 10 version 1809 for accessibility cursor |
| 360 | + * scaling), the method computes the scale factor by dividing the base size by |
| 361 | + * the default system cursor size (32px). If the registry value is not present |
| 362 | + * or cannot be read, the method returns {@code 1} indicating default size. |
| 363 | + * <p> |
| 364 | + * <strong>Note:</strong> This approach is only valid for Windows 10 1809+ with |
| 365 | + * the modern accessibility pointer setting. For classic themes or older Windows |
| 366 | + * versions, this value may not be present or honored. |
| 367 | + * |
| 368 | + * @return the cursor scaling factor (e.g., 1 for default size, 2 for double |
| 369 | + * size, etc.) |
| 370 | + * @since 3.131 |
| 371 | + */ |
| 372 | +public static int getPointerSizeScaleFactor() { |
| 373 | + final int defaultCursorSize = 32; |
| 374 | + int scaleFactor = 1; // Default: standard size |
| 375 | + |
| 376 | + if (OsVersion.IS_WIN10_1809) { |
| 377 | + int[] cursorBaseSize = OS.readRegistryDwords(OS.HKEY_CURRENT_USER, "Control Panel\\Cursors", "CursorBaseSize"); |
| 378 | + if (cursorBaseSize != null && cursorBaseSize.length > 0 && cursorBaseSize[0] > 0) { |
| 379 | + scaleFactor = cursorBaseSize[0] / defaultCursorSize; |
| 380 | + } |
| 381 | + } |
| 382 | + |
| 383 | + return scaleFactor; |
| 384 | +} |
| 385 | + |
352 | 386 | @Override
|
353 | 387 | void destroy () {
|
354 | 388 | device.deregisterResourceWithZoomSupport(this);
|
@@ -635,7 +669,8 @@ public ImageDataCursorHandleProvider(ImageData source, int hotspotX, int hotspot
|
635 | 669 |
|
636 | 670 | @Override
|
637 | 671 | public CursorHandle createHandle(Device device, int zoom) {
|
638 |
| - ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, zoom, DEFAULT_ZOOM); |
| 672 | + int accessibilityFactor = getPointerSizeScaleFactor(); |
| 673 | + ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, zoom * accessibilityFactor, DEFAULT_ZOOM); |
639 | 674 | return setupCursorFromImageData(device, scaledSource, getHotpotXInPixels(zoom),
|
640 | 675 | getHotpotYInPixels(zoom));
|
641 | 676 | }
|
|
0 commit comments