Skip to content

Commit 4735522

Browse files
Register/De-registering resources with zoom support
1 parent 76837d1 commit 4735522

File tree

1 file changed

+17
-0
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics

1 file changed

+17
-0
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public final class Cursor extends Resource {
8282
this.mask = null;
8383
this.hotspotX = -1;
8484
this.hotspotY = -1;
85+
this.device.registerResourceWithZoomSupport(this);
8586
}
8687

8788
/**
@@ -162,6 +163,7 @@ public Cursor(Device device, int style) {
162163
handle = OS.LoadCursor(0, lpCursorName);
163164
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
164165
init();
166+
this.device.registerResourceWithZoomSupport(this);
165167
}
166168

167169
/**
@@ -232,6 +234,7 @@ public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int
232234
handle = OS.CreateCursor(hInst, hotspotX, hotspotY, source.width, source.height, sourceData, maskData);
233235
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
234236
init();
237+
this.device.registerResourceWithZoomSupport(this);
235238
}
236239

237240
/**
@@ -340,6 +343,7 @@ public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
340343
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
341344
isIcon = true;
342345
init();
346+
this.device.registerResourceWithZoomSupport(this);
343347
}
344348

345349
/**
@@ -405,6 +409,7 @@ void destroy () {
405409
// if (OS.GetCursor() == handle) {
406410
// OS.SetCursor(OS.LoadCursor(0, OS.IDC_ARROW));
407411
// }
412+
device.deregisterResourceWithZoomSupport(this);
408413
destroyHandle();
409414
}
410415

@@ -492,6 +497,18 @@ public String toString () {
492497
return "Cursor {" + handle + "}";
493498
}
494499

500+
@Override
501+
void destroyHandlesExcept(Set<Integer> zoomLevels) {
502+
zoomLevelToHandle.entrySet().removeIf(entry -> {
503+
final Integer zoom = entry.getKey();
504+
if (!zoomLevels.contains(zoom) && zoom != DPIUtil.getZoomForAutoscaleProperty(DEFAULT_ZOOM)) {
505+
destroyHandle(entry.getValue());
506+
return true;
507+
}
508+
return false;
509+
});
510+
}
511+
495512
/**
496513
* Invokes platform specific functionality to allocate a new cursor.
497514
* <p>

0 commit comments

Comments
 (0)