OpenJDK / jdk7u / jdk7u-dev / jdk
changeset 4977:8888021b9bae
7154062: [macosx] Mouse cursor isn't updated in applets
Reviewed-by: anthony, art
author | dcherepanov |
---|---|
date | Fri, 04 May 2012 19:33:59 +0400 |
parents | b4a447259412 |
children | 6bf2990ade5d |
files | src/macosx/classes/sun/lwawt/macosx/CCursorManager.java src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java src/macosx/native/sun/awt/CCursorManager.m |
diffstat | 3 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java Thu May 03 21:27:22 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java Fri May 04 19:33:59 2012 +0400 @@ -34,6 +34,7 @@ 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); + public static native void nativeSetAllowsCursorSetInBackground(final boolean allows); private static final int NAMED_CURSOR = -1;
--- a/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Thu May 03 21:27:22 2012 +0100 +++ b/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Fri May 04 19:33:59 2012 +0400 @@ -76,6 +76,12 @@ int screenX = locationOnScreen.x + x; int screenY = locationOnScreen.y + y; + if (eventType == CocoaConstants.NPCocoaEventMouseEntered) { + CCursorManager.nativeSetAllowsCursorSetInBackground(true); + } else if (eventType == CocoaConstants.NPCocoaEventMouseExited) { + CCursorManager.nativeSetAllowsCursorSetInBackground(false); + } + responder.handleMouseEvent(eventType, modifierFlags, buttonNumber, clickCount, x, y, screenX, screenY); }
--- a/src/macosx/native/sun/awt/CCursorManager.m Thu May 03 21:27:22 2012 +0100 +++ b/src/macosx/native/sun/awt/CCursorManager.m Fri May 04 19:33:59 2012 +0400 @@ -137,3 +137,30 @@ return jpt; } + + +JNIEXPORT void JNICALL +Java_sun_lwawt_macosx_CCursorManager_nativeSetAllowsCursorSetInBackground +(JNIEnv *env, jclass class, jboolean allows) +{ + +JNF_COCOA_ENTER(env); +AWT_ASSERT_NOT_APPKIT_THREAD; + + SEL allowsSetInBackground_SEL = @selector(javaSetAllowsCursorSetInBackground:); + if ([[NSCursor class] respondsToSelector:allowsSetInBackground_SEL]) { + [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + NSMethodSignature *allowsSetInBackground_sig = + [[NSCursor class] methodSignatureForSelector:allowsSetInBackground_SEL]; + NSInvocation *invocation = + [NSInvocation invocationWithMethodSignature:allowsSetInBackground_sig]; + BOOL arg = (BOOL)allows; + [invocation setSelector:allowsSetInBackground_SEL]; + [invocation setArgument:&arg atIndex:2]; + [invocation invokeWithTarget:[NSCursor class]]; + }]; + } + +JNF_COCOA_EXIT(env); + +}