jdk/src/macosx/native/sun/awt/AWTWindow.m
changeset 14165 dcb1f9388f85
parent 13777 c94cf7e1bac2
child 14311 b2492ea8d08e
equal deleted inserted replaced
14164:8c51259d0843 14165:dcb1f9388f85
   322             }
   322             }
   323         }
   323         }
   324     }
   324     }
   325 }
   325 }
   326 
   326 
       
   327 + (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window {
       
   328     AWT_ASSERT_APPKIT_THREAD;
       
   329     NSScreen *screen = [window screen];
       
   330     NSDictionary *deviceDescription = [screen deviceDescription];
       
   331     return [deviceDescription objectForKey:@"NSScreenNumber"];
       
   332 }
       
   333 
   327 - (void) dealloc {
   334 - (void) dealloc {
   328 AWT_ASSERT_APPKIT_THREAD;
   335 AWT_ASSERT_APPKIT_THREAD;
   329 
   336 
   330     JNIEnv *env = [ThreadUtilities getJNIEnv];
   337     JNIEnv *env = [ThreadUtilities getJNIEnv];
   331     [self.javaPlatformWindow setJObject:nil withEnv:env];
   338     [self.javaPlatformWindow setJObject:nil withEnv:env];
  1111  * Class:     sun_lwawt_macosx_CPlatformWindow
  1118  * Class:     sun_lwawt_macosx_CPlatformWindow
  1112  * Method:    nativeGetDisplayID_AppKitThread
  1119  * Method:    nativeGetDisplayID_AppKitThread
  1113  * Signature: (J)I
  1120  * Signature: (J)I
  1114  */
  1121  */
  1115 JNIEXPORT jint JNICALL
  1122 JNIEXPORT jint JNICALL
  1116 Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID_1AppKitThread
  1123 Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID
  1117 (JNIEnv *env, jclass clazz, jlong windowPtr)
  1124 (JNIEnv *env, jclass clazz, jlong windowPtr)
  1118 {
  1125 {
  1119     jint ret; // CGDirectDisplayID
  1126     __block jint ret; // CGDirectDisplayID
  1120 
  1127 
  1121 JNF_COCOA_ENTER(env);
  1128 JNF_COCOA_ENTER(env);
  1122 AWT_ASSERT_APPKIT_THREAD;
       
  1123 
  1129 
  1124     NSWindow *window = OBJC(windowPtr);
  1130     NSWindow *window = OBJC(windowPtr);
  1125     NSScreen *screen = [window screen];
  1131 
  1126     NSDictionary *deviceDescription = [screen deviceDescription];
  1132     if ([NSThread isMainThread]) {
  1127     NSNumber *displayID = [deviceDescription objectForKey:@"NSScreenNumber"];
  1133         ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
  1128     ret = (jint)[displayID intValue];
  1134     } else {
       
  1135         [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
       
  1136             ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
       
  1137         }];
       
  1138     }
  1129 
  1139 
  1130 JNF_COCOA_EXIT(env);
  1140 JNF_COCOA_EXIT(env);
  1131 
  1141 
  1132     return ret;
  1142     return ret;
  1133 }
  1143 }