7154062: [macosx] Mouse cursor isn't updated in applets
Reviewed-by: anthony, art
--- a/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java Thu Apr 26 18:15:49 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CCursorManager.java Wed May 02 13:53:06 2012 +0400
@@ -36,6 +36,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/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Thu Apr 26 18:15:49 2012 -0700
+++ b/jdk/src/macosx/classes/sun/lwawt/macosx/CEmbeddedFrame.java Wed May 02 13:53:06 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/jdk/src/macosx/native/sun/awt/CCursorManager.m Thu Apr 26 18:15:49 2012 -0700
+++ b/jdk/src/macosx/native/sun/awt/CCursorManager.m Wed May 02 13:53:06 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);
+
+}