src/macosx/classes/sun/lwawt/macosx/CCursorManager.java

Print this page

        

*** 23,50 **** * questions. */ package sun.lwawt.macosx; ! import java.awt.*; import java.awt.geom.Point2D; ! import sun.lwawt.*; - public class CCursorManager extends LWCursorManager { private static native Point2D nativeGetCursorPosition(); private static native void nativeSetBuiltInCursor(final int type, final String name); private static native void nativeSetCustomCursor(final long imgPtr, final double x, final double y); private static final int NAMED_CURSOR = -1; ! private final static CCursorManager theInstance = new CCursorManager(); public static CCursorManager getInstance() { return theInstance; } ! Cursor currentCursor; private CCursorManager() { } @Override protected Point getCursorPosition() { --- 23,52 ---- * questions. */ package sun.lwawt.macosx; ! import sun.lwawt.LWCursorManager; ! ! import java.awt.Cursor; ! import java.awt.Point; import java.awt.geom.Point2D; ! final class CCursorManager extends LWCursorManager { private static native Point2D nativeGetCursorPosition(); private static native void nativeSetBuiltInCursor(final int type, final String name); private static native void nativeSetCustomCursor(final long imgPtr, final double x, final double y); private static final int NAMED_CURSOR = -1; ! private static final CCursorManager theInstance = new CCursorManager(); public static CCursorManager getInstance() { return theInstance; } ! private volatile Cursor currentCursor; private CCursorManager() { } @Override protected Point getCursorPosition() {
*** 60,82 **** final Point2D nativePosition = nativeGetCursorPosition(); return new Point((int)nativePosition.getX(), (int)nativePosition.getY()); } @Override ! protected void setCursor(final LWWindowPeer windowUnderCursor, final Cursor cursor) { ! if (cursor == currentCursor) return; if (cursor == null) { nativeSetBuiltInCursor(Cursor.DEFAULT_CURSOR, null); return; } if (cursor instanceof CCustomCursor) { ! final CCustomCursor customCursor = ((CCustomCursor)cursor); final long imagePtr = customCursor.getImageData(); final Point hotSpot = customCursor.getHotSpot(); ! if(imagePtr != 0L) nativeSetCustomCursor(imagePtr, hotSpot.x, hotSpot.y); return; } final int type = cursor.getType(); if (type != Cursor.CUSTOM_CURSOR) { --- 62,89 ---- final Point2D nativePosition = nativeGetCursorPosition(); return new Point((int)nativePosition.getX(), (int)nativePosition.getY()); } @Override ! protected void setCursor(final Cursor cursor) { ! if (cursor == currentCursor) { ! return; ! } ! currentCursor = cursor; if (cursor == null) { nativeSetBuiltInCursor(Cursor.DEFAULT_CURSOR, null); return; } if (cursor instanceof CCustomCursor) { ! final CCustomCursor customCursor = (CCustomCursor) cursor; final long imagePtr = customCursor.getImageData(); + if (imagePtr != 0L) { final Point hotSpot = customCursor.getHotSpot(); ! nativeSetCustomCursor(imagePtr, hotSpot.x, hotSpot.y); ! } return; } final int type = cursor.getType(); if (type != Cursor.CUSTOM_CURSOR) {
*** 92,119 **** // do something special throw new RuntimeException("Unimplemented"); } - static long getNativeWindow(final LWWindowPeer window) { - if (window == null) return 0; - final CPlatformWindow platformWindow = (CPlatformWindow)window.getPlatformWindow(); - if (platformWindow == null) return 0; - return platformWindow.getNSWindowPtr(); - } - // package private methods to handle cursor change during drag-and-drop private boolean isDragging = false; private Point dragPos = null; synchronized void startDrag(int x, int y) { if (isDragging) { throw new RuntimeException("Invalid Drag state in CCursorManager!"); } - isDragging = true; - dragPos = new Point(x, y); } synchronized void updateDragPosition(int x, int y) { if (!isDragging) { --- 99,117 ----