87 /* NSWindow overrides */ \ 88 - (BOOL) canBecomeKeyWindow { \ 89 return [(AWTWindow*)[self delegate] canBecomeKeyWindow]; \ 90 } \ 91 \ 92 - (BOOL) canBecomeMainWindow { \ 93 return [(AWTWindow*)[self delegate] canBecomeMainWindow]; \ 94 } \ 95 \ 96 - (BOOL) worksWhenModal { \ 97 return [(AWTWindow*)[self delegate] worksWhenModal]; \ 98 } \ 99 \ 100 - (void)sendEvent:(NSEvent *)event { \ 101 [(AWTWindow*)[self delegate] sendEvent:event]; \ 102 [super sendEvent:event]; \ 103 } 104 105 @implementation AWTWindow_Normal 106 AWT_NS_WINDOW_IMPLEMENTATION 107 @end 108 @implementation AWTWindow_Panel 109 AWT_NS_WINDOW_IMPLEMENTATION 110 @end 111 // END of NSWindow/NSPanel descendants implementation 112 // -------------------------------------------------------------- 113 114 115 @implementation AWTWindow 116 117 @synthesize nsWindow; 118 @synthesize javaPlatformWindow; 119 @synthesize javaMenuBar; 120 @synthesize javaMinSize; 121 @synthesize javaMaxSize; 122 @synthesize styleBits; 123 @synthesize isEnabled; 124 @synthesize ownerWindow; 125 @synthesize preFullScreenLevel; 126 382 383 JNIEnv *env = [ThreadUtilities getJNIEnv]; 384 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 385 if (platformWindow != NULL) { 386 static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow, 387 "checkBlockingAndOrder", "()Z"); 388 JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder); 389 (*env)->DeleteLocalRef(env, platformWindow); 390 } 391 } 392 393 return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN); 394 } 395 396 - (BOOL) worksWhenModal { 397 AWT_ASSERT_APPKIT_THREAD; 398 return IS(self.styleBits, MODAL_EXCLUDED); 399 } 400 401 402 // Gesture support 403 - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { 404 AWT_ASSERT_APPKIT_THREAD; 405 406 JNIEnv *env = [ThreadUtilities getJNIEnv]; 407 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 408 if (platformWindow != NULL) { 409 // extract the target AWT Window object out of the CPlatformWindow 410 static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); 411 jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); 412 if (awtWindow != NULL) { 413 // translate the point into Java coordinates 414 NSPoint loc = [event locationInWindow]; 415 loc.y = [self.nsWindow frame].size.height - loc.y; 416 417 // send up to the GestureHandler to recursively dispatch on the AWT event thread 418 static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler"); 419 static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V"); 420 JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b); 421 (*env)->DeleteLocalRef(env, awtWindow); 422 } 423 (*env)->DeleteLocalRef(env, platformWindow); 424 } 425 } 426 427 - (void)beginGestureWithEvent:(NSEvent *)event { 428 [self postGesture:event 429 as:com_apple_eawt_event_GestureHandler_PHASE 430 a:-1.0 431 b:0.0]; 432 } 433 434 - (void)endGestureWithEvent:(NSEvent *)event { 435 [self postGesture:event 436 as:com_apple_eawt_event_GestureHandler_PHASE 437 a:1.0 438 b:0.0]; 439 } 440 441 - (void)magnifyWithEvent:(NSEvent *)event { 442 [self postGesture:event 443 as:com_apple_eawt_event_GestureHandler_MAGNIFY 444 a:[event magnification] 445 b:0.0]; 446 } 447 448 - (void)rotateWithEvent:(NSEvent *)event { 449 [self postGesture:event 450 as:com_apple_eawt_event_GestureHandler_ROTATE 451 a:[event rotation] 452 b:0.0]; 453 } 454 455 - (void)swipeWithEvent:(NSEvent *)event { 456 [self postGesture:event 457 as:com_apple_eawt_event_GestureHandler_SWIPE 458 a:[event deltaX] 459 b:[event deltaY]]; 460 } 461 462 463 // NSWindowDelegate methods 464 465 - (void) _deliverMoveResizeEvent { 466 AWT_ASSERT_APPKIT_THREAD; 467 468 // deliver the event if this is a user-initiated live resize or as a side-effect 469 // of a Java initiated resize, because AppKit can override the bounds and force 470 // the bounds of the window to avoid the Dock or remain on screen. 471 [AWTToolkit eventCountPlusPlus]; 472 JNIEnv *env = [ThreadUtilities getJNIEnv]; 473 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 474 if (platformWindow == NULL) { 475 // TODO: create generic AWT assert 476 } 477 478 NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); 479 480 static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V"); 481 JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent, 482 (jint)frame.origin.x, | 87 /* NSWindow overrides */ \ 88 - (BOOL) canBecomeKeyWindow { \ 89 return [(AWTWindow*)[self delegate] canBecomeKeyWindow]; \ 90 } \ 91 \ 92 - (BOOL) canBecomeMainWindow { \ 93 return [(AWTWindow*)[self delegate] canBecomeMainWindow]; \ 94 } \ 95 \ 96 - (BOOL) worksWhenModal { \ 97 return [(AWTWindow*)[self delegate] worksWhenModal]; \ 98 } \ 99 \ 100 - (void)sendEvent:(NSEvent *)event { \ 101 [(AWTWindow*)[self delegate] sendEvent:event]; \ 102 [super sendEvent:event]; \ 103 } 104 105 @implementation AWTWindow_Normal 106 AWT_NS_WINDOW_IMPLEMENTATION 107 108 // Gesture support 109 - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { 110 AWT_ASSERT_APPKIT_THREAD; 111 112 JNIEnv *env = [ThreadUtilities getJNIEnv]; 113 jobject platformWindow = [((AWTWindow *)self.delegate).javaPlatformWindow jObjectWithEnv:env]; 114 if (platformWindow != NULL) { 115 // extract the target AWT Window object out of the CPlatformWindow 116 static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); 117 jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); 118 if (awtWindow != NULL) { 119 // translate the point into Java coordinates 120 NSPoint loc = [event locationInWindow]; 121 loc.y = [self frame].size.height - loc.y; 122 123 // send up to the GestureHandler to recursively dispatch on the AWT event thread 124 static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler"); 125 static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V"); 126 JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b); 127 (*env)->DeleteLocalRef(env, awtWindow); 128 } 129 (*env)->DeleteLocalRef(env, platformWindow); 130 } 131 } 132 133 - (void)beginGestureWithEvent:(NSEvent *)event { 134 [self postGesture:event 135 as:com_apple_eawt_event_GestureHandler_PHASE 136 a:-1.0 137 b:0.0]; 138 } 139 140 - (void)endGestureWithEvent:(NSEvent *)event { 141 [self postGesture:event 142 as:com_apple_eawt_event_GestureHandler_PHASE 143 a:1.0 144 b:0.0]; 145 } 146 147 - (void)magnifyWithEvent:(NSEvent *)event { 148 [self postGesture:event 149 as:com_apple_eawt_event_GestureHandler_MAGNIFY 150 a:[event magnification] 151 b:0.0]; 152 } 153 154 - (void)rotateWithEvent:(NSEvent *)event { 155 [self postGesture:event 156 as:com_apple_eawt_event_GestureHandler_ROTATE 157 a:[event rotation] 158 b:0.0]; 159 } 160 161 - (void)swipeWithEvent:(NSEvent *)event { 162 [self postGesture:event 163 as:com_apple_eawt_event_GestureHandler_SWIPE 164 a:[event deltaX] 165 b:[event deltaY]]; 166 } 167 168 @end 169 @implementation AWTWindow_Panel 170 AWT_NS_WINDOW_IMPLEMENTATION 171 @end 172 // END of NSWindow/NSPanel descendants implementation 173 // -------------------------------------------------------------- 174 175 176 @implementation AWTWindow 177 178 @synthesize nsWindow; 179 @synthesize javaPlatformWindow; 180 @synthesize javaMenuBar; 181 @synthesize javaMinSize; 182 @synthesize javaMaxSize; 183 @synthesize styleBits; 184 @synthesize isEnabled; 185 @synthesize ownerWindow; 186 @synthesize preFullScreenLevel; 187 443 444 JNIEnv *env = [ThreadUtilities getJNIEnv]; 445 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 446 if (platformWindow != NULL) { 447 static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow, 448 "checkBlockingAndOrder", "()Z"); 449 JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder); 450 (*env)->DeleteLocalRef(env, platformWindow); 451 } 452 } 453 454 return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN); 455 } 456 457 - (BOOL) worksWhenModal { 458 AWT_ASSERT_APPKIT_THREAD; 459 return IS(self.styleBits, MODAL_EXCLUDED); 460 } 461 462 463 // NSWindowDelegate methods 464 465 - (void) _deliverMoveResizeEvent { 466 AWT_ASSERT_APPKIT_THREAD; 467 468 // deliver the event if this is a user-initiated live resize or as a side-effect 469 // of a Java initiated resize, because AppKit can override the bounds and force 470 // the bounds of the window to avoid the Dock or remain on screen. 471 [AWTToolkit eventCountPlusPlus]; 472 JNIEnv *env = [ThreadUtilities getJNIEnv]; 473 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; 474 if (platformWindow == NULL) { 475 // TODO: create generic AWT assert 476 } 477 478 NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); 479 480 static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V"); 481 JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent, 482 (jint)frame.origin.x, |