提交 5129b460 编写于 作者: A alexsch

7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again

Reviewed-by: serb, anthony
上级 019262a4
...@@ -65,7 +65,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -65,7 +65,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
private static native void nativeDispose(long nsWindowPtr); private static native void nativeDispose(long nsWindowPtr);
private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse(); private static native CPlatformWindow nativeGetTopmostPlatformWindowUnderMouse();
private static native int nativeGetNSWindowDisplayID_AppKitThread(long nsWindowPtr); private static native int nativeGetNSWindowDisplayID(long nsWindowPtr);
// Loger to report issues happened during execution but that do not affect functionality // Loger to report issues happened during execution but that do not affect functionality
private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow"); private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
...@@ -444,7 +444,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo ...@@ -444,7 +444,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
public GraphicsDevice getGraphicsDevice() { public GraphicsDevice getGraphicsDevice() {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
CGraphicsEnvironment cge = (CGraphicsEnvironment)ge; CGraphicsEnvironment cge = (CGraphicsEnvironment)ge;
int displayID = nativeGetNSWindowDisplayID_AppKitThread(getNSWindowPtr()); int displayID = nativeGetNSWindowDisplayID(getNSWindowPtr());
GraphicsDevice gd = cge.getScreenDevice(displayID); GraphicsDevice gd = cge.getScreenDevice(displayID);
if (gd == null) { if (gd == null) {
// this could possibly happen during device removal // this could possibly happen during device removal
......
...@@ -324,6 +324,13 @@ AWT_ASSERT_APPKIT_THREAD; ...@@ -324,6 +324,13 @@ AWT_ASSERT_APPKIT_THREAD;
} }
} }
+ (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window {
AWT_ASSERT_APPKIT_THREAD;
NSScreen *screen = [window screen];
NSDictionary *deviceDescription = [screen deviceDescription];
return [deviceDescription objectForKey:@"NSScreenNumber"];
}
- (void) dealloc { - (void) dealloc {
AWT_ASSERT_APPKIT_THREAD; AWT_ASSERT_APPKIT_THREAD;
...@@ -1113,19 +1120,22 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou ...@@ -1113,19 +1120,22 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMou
* Signature: (J)I * Signature: (J)I
*/ */
JNIEXPORT jint JNICALL JNIEXPORT jint JNICALL
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID_1AppKitThread Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID
(JNIEnv *env, jclass clazz, jlong windowPtr) (JNIEnv *env, jclass clazz, jlong windowPtr)
{ {
jint ret; // CGDirectDisplayID __block jint ret; // CGDirectDisplayID
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWT_ASSERT_APPKIT_THREAD;
NSWindow *window = OBJC(windowPtr); NSWindow *window = OBJC(windowPtr);
NSScreen *screen = [window screen];
NSDictionary *deviceDescription = [screen deviceDescription]; if ([NSThread isMainThread]) {
NSNumber *displayID = [deviceDescription objectForKey:@"NSScreenNumber"]; ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
ret = (jint)[displayID intValue]; } else {
[JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
}];
}
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册