349 350 - (void) dealloc { 351 AWT_ASSERT_APPKIT_THREAD; 352 353 JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; 354 [self.javaPlatformWindow setJObject:nil withEnv:env]; 355 356 self.nsWindow = nil; 357 self.ownerWindow = nil; 358 [super dealloc]; 359 } 360 361 // NSWindow overrides 362 - (BOOL) canBecomeKeyWindow { 363 AWT_ASSERT_APPKIT_THREAD; 364 return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY); 365 } 366 367 - (BOOL) canBecomeMainWindow { 368 AWT_ASSERT_APPKIT_THREAD; 369 if(!self.isEnabled){ 370 // Native system can bring up the NSWindow to 371 // the top even if the window is not main. 372 // We should bring up the modal dialog manually 373 [AWTToolkit eventCountPlusPlus]; 374 375 JNIEnv *env = [ThreadUtilities getJNIEnv]; 376 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 377 if (platformWindow != NULL) { 378 static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow, 379 "checkBlockingAndOrder", "()Z"); 380 JNFCallVoidMethod(env, platformWindow, jm_checkBlockingAndOrder); 381 (*env)->DeleteLocalRef(env, platformWindow); 382 } 383 } 384 385 return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN); 386 } 387 388 - (BOOL) worksWhenModal { 389 AWT_ASSERT_APPKIT_THREAD; 390 return IS(self.styleBits, MODAL_EXCLUDED); 391 } 392 393 394 // Gesture support 395 - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { 396 AWT_ASSERT_APPKIT_THREAD; 397 398 JNIEnv *env = [ThreadUtilities getJNIEnv]; 399 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 400 if (platformWindow != NULL) { | 349 350 - (void) dealloc { 351 AWT_ASSERT_APPKIT_THREAD; 352 353 JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; 354 [self.javaPlatformWindow setJObject:nil withEnv:env]; 355 356 self.nsWindow = nil; 357 self.ownerWindow = nil; 358 [super dealloc]; 359 } 360 361 // NSWindow overrides 362 - (BOOL) canBecomeKeyWindow { 363 AWT_ASSERT_APPKIT_THREAD; 364 return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY); 365 } 366 367 - (BOOL) canBecomeMainWindow { 368 AWT_ASSERT_APPKIT_THREAD; 369 if (!self.isEnabled) { 370 // Native system can bring up the NSWindow to 371 // the top even if the window is not main. 372 // We should bring up the modal dialog manually 373 [AWTToolkit eventCountPlusPlus]; 374 375 JNIEnv *env = [ThreadUtilities getJNIEnv]; 376 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 377 if (platformWindow != NULL) { 378 static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow, 379 "checkBlockingAndOrder", "()Z"); 380 JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder); 381 (*env)->DeleteLocalRef(env, platformWindow); 382 } 383 } 384 385 return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN); 386 } 387 388 - (BOOL) worksWhenModal { 389 AWT_ASSERT_APPKIT_THREAD; 390 return IS(self.styleBits, MODAL_EXCLUDED); 391 } 392 393 394 // Gesture support 395 - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { 396 AWT_ASSERT_APPKIT_THREAD; 397 398 JNIEnv *env = [ThreadUtilities getJNIEnv]; 399 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 400 if (platformWindow != NULL) { |