src/macosx/native/sun/awt/AWTWindow.m
Print this page
*** 322,331 ****
--- 322,338 ----
}
}
}
}
+ + (NSNumber *) GetNSWindowDisplayID_AppKitThread:(NSWindow *)window {
+ AWT_ASSERT_APPKIT_THREAD;
+ NSScreen *screen = [window screen];
+ NSDictionary *deviceDescription = [screen deviceDescription];
+ return [deviceDescription objectForKey:@"NSScreenNumber"];
+ }
+
- (void) dealloc {
AWT_ASSERT_APPKIT_THREAD;
JNIEnv *env = [ThreadUtilities getJNIEnv];
[self.javaPlatformWindow setJObject:nil withEnv:env];
*** 1111,1133 ****
* Class: sun_lwawt_macosx_CPlatformWindow
* Method: nativeGetDisplayID_AppKitThread
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
! Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID_1AppKitThread
(JNIEnv *env, jclass clazz, jlong windowPtr)
{
! jint ret; // CGDirectDisplayID
JNF_COCOA_ENTER(env);
- AWT_ASSERT_APPKIT_THREAD;
NSWindow *window = OBJC(windowPtr);
! NSScreen *screen = [window screen];
! NSDictionary *deviceDescription = [screen deviceDescription];
! NSNumber *displayID = [deviceDescription objectForKey:@"NSScreenNumber"];
! ret = (jint)[displayID intValue];
JNF_COCOA_EXIT(env);
return ret;
}
--- 1118,1143 ----
* Class: sun_lwawt_macosx_CPlatformWindow
* Method: nativeGetDisplayID_AppKitThread
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
! Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID
(JNIEnv *env, jclass clazz, jlong windowPtr)
{
! __block jint ret; // CGDirectDisplayID
JNF_COCOA_ENTER(env);
NSWindow *window = OBJC(windowPtr);
!
! if ([NSThread isMainThread]) {
! ret = (jint)[[AWTWindow GetNSWindowDisplayID_AppKitThread: window] intValue];
! } else {
! [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
! ret = (jint)[[AWTWindow GetNSWindowDisplayID_AppKitThread: window] intValue];
! }];
! }
JNF_COCOA_EXIT(env);
return ret;
}