diff --git a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/io/SqueakDisplay.java b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/io/SqueakDisplay.java index aa7ab598a..b8ca5b334 100644 --- a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/io/SqueakDisplay.java +++ b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/io/SqueakDisplay.java @@ -321,7 +321,9 @@ public void setCursor(final int[] cursorWords, final int[] mask, final int width } } } - cursor = TOOLKIT.createCustomCursor(bufferedImage, new Point(offsetX, offsetY), "TruffleSqueak Cursor"); + // Ensure hotspot is within cursor bounds. + final Point hotSpot = new Point(Math.min(Math.max(offsetX, 1), width - 1), Math.min(Math.max(offsetY, 1), height - 1)); + cursor = TOOLKIT.createCustomCursor(bufferedImage, hotSpot, "TruffleSqueak Cursor"); } frame.setCursor(cursor); } diff --git a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/primitives/impl/IOPrimitives.java b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/primitives/impl/IOPrimitives.java index 1ddf2661c..33971067c 100644 --- a/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/primitives/impl/IOPrimitives.java +++ b/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/nodes/primitives/impl/IOPrimitives.java @@ -217,12 +217,16 @@ protected final PointersObject doCursor(final PointersObject receiver, final Poi final PointersObject offset = receiver.getFormOffset(cursorReadNode); final int offsetX = Math.abs(offsetReadNode.executeInt(offset, POINT.X)); final int offsetY = Math.abs(offsetReadNode.executeInt(offset, POINT.Y)); + final int[] mask; + final int realDepth; if (depthProfile.profile(depth == 1)) { - final int[] mask = cursorReadNode.executeNative(maskObject, FORM.BITS).getIntStorage(); - image.getDisplay().setCursor(words, mask, width, height, 2, offsetX, offsetY); + mask = cursorReadNode.executeNative(maskObject, FORM.BITS).getIntStorage(); + realDepth = 2; } else { - image.getDisplay().setCursor(words, null, width, height, depth, offsetX, offsetY); + mask = null; + realDepth = depth; } + image.getDisplay().setCursor(words, mask, width, height, realDepth, offsetX, offsetY); } return receiver; }