588 // The window will be closed (if allowed) as result of sending Java event
589 return NO;
590 }
591
592
593 - (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env {
594 static JNF_CLASS_CACHE(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler");
595 static JNF_STATIC_MEMBER_CACHE(jm_notifyFullScreenOperation, jc_FullScreenHandler, "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V");
596 static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
597 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
598 if (platformWindow != NULL) {
599 jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
600 if (awtWindow != NULL) {
601 JNFCallStaticVoidMethod(env, jm_notifyFullScreenOperation, awtWindow, op);
602 (*env)->DeleteLocalRef(env, awtWindow);
603 }
604 (*env)->DeleteLocalRef(env, platformWindow);
605 }
606 }
607
608
609 - (void)windowWillEnterFullScreen:(NSNotification *)notification {
610 static JNF_MEMBER_CACHE(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V");
611 JNIEnv *env = [ThreadUtilities getJNIEnv];
612 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
613 if (platformWindow != NULL) {
614 JNFCallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen);
615 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env];
616 (*env)->DeleteLocalRef(env, platformWindow);
617 }
618 }
619
620 - (void)windowDidEnterFullScreen:(NSNotification *)notification {
621 static JNF_MEMBER_CACHE(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V");
622 JNIEnv *env = [ThreadUtilities getJNIEnv];
623 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
624 if (platformWindow != NULL) {
625 JNFCallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen);
626 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env];
627 (*env)->DeleteLocalRef(env, platformWindow);
628 }
629 }
630
631 - (void)windowWillExitFullScreen:(NSNotification *)notification {
632 static JNF_MEMBER_CACHE(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V");
633 JNIEnv *env = [ThreadUtilities getJNIEnv];
634 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
635 if (platformWindow != NULL) {
636 JNFCallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen);
637 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env];
638 (*env)->DeleteLocalRef(env, platformWindow);
639 }
640 }
641
642 - (void)windowDidExitFullScreen:(NSNotification *)notification {
643 static JNF_MEMBER_CACHE(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V");
644 JNIEnv *env = [ThreadUtilities getJNIEnv];
645 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
646 if (platformWindow != NULL) {
647 JNFCallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen);
648 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env];
649 (*env)->DeleteLocalRef(env, platformWindow);
650 }
651 }
652
653 - (void)sendEvent:(NSEvent *)event {
654 if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
655
656 NSPoint p = [NSEvent mouseLocation];
657 NSRect frame = [self.nsWindow frame];
658 NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame];
659
660 // Check if the click happened in the non-client area (title bar)
661 if (p.y >= (frame.origin.y + contentRect.size.height)) {
662 JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
663 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
664 // Currently, no need to deliver the whole NSEvent.
665 static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
666 JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
667 }
668 }
669 }
670
821
822 // if ([self isKeyWindow]) {
823 [CMenuBar activate:window.javaMenuBar modallyDisabled:NO];
824 // }
825 }];
826
827 JNF_COCOA_EXIT(env);
828 }
829
830 /*
831 * Class: sun_lwawt_macosx_CPlatformWindow
832 * Method: nativeGetNSWindowInsets
833 * Signature: (J)Ljava/awt/Insets;
834 */
835 JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets
836 (JNIEnv *env, jclass clazz, jlong windowPtr)
837 {
838 jobject ret = NULL;
839
840 JNF_COCOA_ENTER(env);
841 AWT_ASSERT_NOT_APPKIT_THREAD;
842
843 NSWindow *nsWindow = OBJC(windowPtr);
844 __block NSRect contentRect = NSZeroRect;
845 __block NSRect frame = NSZeroRect;
846
847 [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
848 AWT_ASSERT_APPKIT_THREAD;
849
850 frame = [nsWindow frame];
851 contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]];
852 }];
853
854 jint top = (jint)(frame.size.height - contentRect.size.height);
855 jint left = (jint)(contentRect.origin.x - frame.origin.x);
856 jint bottom = (jint)(contentRect.origin.y - frame.origin.y);
857 jint right = (jint)(frame.size.width - (contentRect.size.width + left));
858
859 static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets");
860 static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V");
861 ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right);
862
863 JNF_COCOA_EXIT(env);
864 return ret;
865 }
866
867 /*
|
588 // The window will be closed (if allowed) as result of sending Java event
589 return NO;
590 }
591
592
593 - (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env {
594 static JNF_CLASS_CACHE(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler");
595 static JNF_STATIC_MEMBER_CACHE(jm_notifyFullScreenOperation, jc_FullScreenHandler, "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V");
596 static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
597 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
598 if (platformWindow != NULL) {
599 jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
600 if (awtWindow != NULL) {
601 JNFCallStaticVoidMethod(env, jm_notifyFullScreenOperation, awtWindow, op);
602 (*env)->DeleteLocalRef(env, awtWindow);
603 }
604 (*env)->DeleteLocalRef(env, platformWindow);
605 }
606 }
607
608 - (void)windowWillEnterFullScreen:(NSNotification *)notification {
609 JNIEnv *env = [ThreadUtilities getJNIEnv];
610 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env];
611 }
612
613 - (void)windowDidEnterFullScreen:(NSNotification *)notification {
614 JNIEnv *env = [ThreadUtilities getJNIEnv];
615 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env];
616 }
617
618 - (void)windowWillExitFullScreen:(NSNotification *)notification {
619 JNIEnv *env = [ThreadUtilities getJNIEnv];
620 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env];
621 }
622
623 - (void)windowDidExitFullScreen:(NSNotification *)notification {
624 JNIEnv *env = [ThreadUtilities getJNIEnv];
625 [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env];
626 }
627
628 - (void)sendEvent:(NSEvent *)event {
629 if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
630
631 NSPoint p = [NSEvent mouseLocation];
632 NSRect frame = [self.nsWindow frame];
633 NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame];
634
635 // Check if the click happened in the non-client area (title bar)
636 if (p.y >= (frame.origin.y + contentRect.size.height)) {
637 JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
638 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
639 // Currently, no need to deliver the whole NSEvent.
640 static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
641 JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
642 }
643 }
644 }
645
796
797 // if ([self isKeyWindow]) {
798 [CMenuBar activate:window.javaMenuBar modallyDisabled:NO];
799 // }
800 }];
801
802 JNF_COCOA_EXIT(env);
803 }
804
805 /*
806 * Class: sun_lwawt_macosx_CPlatformWindow
807 * Method: nativeGetNSWindowInsets
808 * Signature: (J)Ljava/awt/Insets;
809 */
810 JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets
811 (JNIEnv *env, jclass clazz, jlong windowPtr)
812 {
813 jobject ret = NULL;
814
815 JNF_COCOA_ENTER(env);
816
817 NSWindow *nsWindow = OBJC(windowPtr);
818 __block NSRect contentRect = NSZeroRect;
819 __block NSRect frame = NSZeroRect;
820
821 [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
822 AWT_ASSERT_APPKIT_THREAD;
823
824 frame = [nsWindow frame];
825 contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]];
826 }];
827
828 jint top = (jint)(frame.size.height - contentRect.size.height);
829 jint left = (jint)(contentRect.origin.x - frame.origin.x);
830 jint bottom = (jint)(contentRect.origin.y - frame.origin.y);
831 jint right = (jint)(frame.size.width - (contentRect.size.width + left));
832
833 static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets");
834 static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V");
835 ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right);
836
837 JNF_COCOA_EXIT(env);
838 return ret;
839 }
840
841 /*
|