< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m

Print this page
rev 54094 : 8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code
rev 54096 : 8259651: [macOS] Replace JNF_COCOA_ENTER/EXIT macros
rev 54097 : 8259869: [macOS] Remove desktop module dependencies on JNF Reference APIs
rev 54098 : 8260616: Removing remaining JNF dependencies in the java.desktop module
8259729: Missed JNFInstanceOf -> IsInstanceOf conversion

*** 22,53 **** * or visit www.oracle.com if you need additional information or have any * questions. */ #import <Cocoa/Cocoa.h> - #import <JavaNativeFoundation/JavaNativeFoundation.h> #import "sun_lwawt_macosx_CPlatformWindow.h" #import "com_apple_eawt_event_GestureHandler.h" #import "com_apple_eawt_FullScreenHandler.h" #import "ApplicationDelegate.h" #import "AWTWindow.h" #import "AWTView.h" #import "GeomUtilities.h" #import "ThreadUtilities.h" #define MASK(KEY) \ (sun_lwawt_macosx_CPlatformWindow_ ## KEY) #define IS(BITS, KEY) \ ((BITS & MASK(KEY)) != 0) #define SET(BITS, KEY, VALUE) \ BITS = VALUE ? BITS | MASK(KEY) : BITS & ~MASK(KEY) ! static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow"); // Cocoa windowDidBecomeKey/windowDidResignKey notifications // doesn't provide information about "opposite" window, so we // have to do a bit of tracking. This variable points to a window // which had been the key window just before a new key window --- 22,58 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ #import <Cocoa/Cocoa.h> #import "sun_lwawt_macosx_CPlatformWindow.h" #import "com_apple_eawt_event_GestureHandler.h" #import "com_apple_eawt_FullScreenHandler.h" #import "ApplicationDelegate.h" #import "AWTWindow.h" #import "AWTView.h" #import "GeomUtilities.h" #import "ThreadUtilities.h" + #import "JNIUtilities.h" #define MASK(KEY) \ (sun_lwawt_macosx_CPlatformWindow_ ## KEY) #define IS(BITS, KEY) \ ((BITS & MASK(KEY)) != 0) #define SET(BITS, KEY, VALUE) \ BITS = VALUE ? BITS | MASK(KEY) : BITS & ~MASK(KEY) ! static jclass jc_CPlatformWindow = NULL; ! #define GET_CPLATFORM_WINDOW_CLASS() \ ! GET_CLASS(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow"); ! ! #define GET_CPLATFORM_WINDOW_CLASS_RETURN(ret) \ ! GET_CLASS_RETURN(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow", ret); // Cocoa windowDidBecomeKey/windowDidResignKey notifications // doesn't provide information about "opposite" window, so we // have to do a bit of tracking. This variable points to a window // which had been the key window just before a new key window
*** 108,131 **** // Gesture support - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [((AWTWindow *)self.delegate).javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { // extract the target AWT Window object out of the CPlatformWindow ! static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); ! jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); if (awtWindow != NULL) { // translate the point into Java coordinates NSPoint loc = [event locationInWindow]; loc.y = [self frame].size.height - loc.y; // send up to the GestureHandler to recursively dispatch on the AWT event thread ! static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler"); ! static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V"); ! JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b); (*env)->DeleteLocalRef(env, awtWindow); } (*env)->DeleteLocalRef(env, platformWindow); } } --- 113,140 ---- // Gesture support - (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b { AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, ((AWTWindow *)self.delegate).javaPlatformWindow); if (platformWindow != NULL) { // extract the target AWT Window object out of the CPlatformWindow ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_FIELD(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); ! jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target); if (awtWindow != NULL) { // translate the point into Java coordinates NSPoint loc = [event locationInWindow]; loc.y = [self frame].size.height - loc.y; // send up to the GestureHandler to recursively dispatch on the AWT event thread ! DECLARE_CLASS(jc_GestureHandler, "com/apple/eawt/event/GestureHandler"); ! DECLARE_METHOD(sjm_handleGestureFromNative, jc_GestureHandler, ! "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V"); ! (*env)->CallStaticVoidMethod(env, jc_GestureHandler, sjm_handleGestureFromNative, ! awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, awtWindow); } (*env)->DeleteLocalRef(env, platformWindow); } }
*** 268,278 **** if (IS(mask, TRANSPARENT_TITLE_BAR) && [self.nsWindow respondsToSelector:@selector(setTitlebarAppearsTransparent:)]) { [self.nsWindow setTitlebarAppearsTransparent:IS(bits, TRANSPARENT_TITLE_BAR)]; } } ! - (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow ownerWindow:owner styleBits:(jint)bits frameRect:(NSRect)rect contentView:(NSView *)view { --- 277,287 ---- if (IS(mask, TRANSPARENT_TITLE_BAR) && [self.nsWindow respondsToSelector:@selector(setTitlebarAppearsTransparent:)]) { [self.nsWindow setTitlebarAppearsTransparent:IS(bits, TRANSPARENT_TITLE_BAR)]; } } ! - (id) initWithPlatformWindow:(jobject)platformWindow ownerWindow:owner styleBits:(jint)bits frameRect:(NSRect)rect contentView:(NSView *)view {
*** 458,468 **** - (void) dealloc { AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! [self.javaPlatformWindow setJObject:nil withEnv:env]; self.javaPlatformWindow = nil; self.nsWindow = nil; self.ownerWindow = nil; [super dealloc]; } --- 467,477 ---- - (void) dealloc { AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! (*env)->DeleteWeakGlobalRef(env, self.javaPlatformWindow); self.javaPlatformWindow = nil; self.nsWindow = nil; self.ownerWindow = nil; [super dealloc]; }
*** 470,483 **** // Tests whether window is blocked by modal dialog/window - (BOOL) isBlocked { BOOL isBlocked = NO; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_isBlocked, jc_CPlatformWindow, "isBlocked", "()Z"); ! isBlocked = JNFCallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO; (*env)->DeleteLocalRef(env, platformWindow); } return isBlocked; } --- 479,494 ---- // Tests whether window is blocked by modal dialog/window - (BOOL) isBlocked { BOOL isBlocked = NO; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS_RETURN(isBlocked); ! DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isBlocked", "()Z", isBlocked); ! isBlocked = (*env)->CallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO; ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } return isBlocked; }
*** 485,498 **** // Test whether window is simple window and owned by embedded frame - (BOOL) isSimpleWindowOwnedByEmbeddedFrame { BOOL isSimpleWindowOwnedByEmbeddedFrame = NO; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z"); ! isSimpleWindowOwnedByEmbeddedFrame = JNFCallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO; (*env)->DeleteLocalRef(env, platformWindow); } return isSimpleWindowOwnedByEmbeddedFrame; } --- 496,511 ---- // Test whether window is simple window and owned by embedded frame - (BOOL) isSimpleWindowOwnedByEmbeddedFrame { BOOL isSimpleWindowOwnedByEmbeddedFrame = NO; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS_RETURN(NO); ! DECLARE_METHOD_RETURN(jm_isBlocked, jc_CPlatformWindow, "isSimpleWindowOwnedByEmbeddedFrame", "()Z", NO); ! isSimpleWindowOwnedByEmbeddedFrame = (*env)->CallBooleanMethod(env, platformWindow, jm_isBlocked) == JNI_TRUE ? YES : NO; ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } return isSimpleWindowOwnedByEmbeddedFrame; }
*** 504,517 **** if ([AWTWindow isAWTWindow:window] && [window delegate] != nil) { AWTWindow *awtWindow = (AWTWindow *)[window delegate]; [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [awtWindow.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z"); ! isVisible = JNFCallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO; (*env)->DeleteLocalRef(env, platformWindow); } } return isVisible; --- 517,532 ---- if ([AWTWindow isAWTWindow:window] && [window delegate] != nil) { AWTWindow *awtWindow = (AWTWindow *)[window delegate]; [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, awtWindow.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS_RETURN(isVisible); ! DECLARE_METHOD_RETURN(jm_isVisible, jc_CPlatformWindow, "isVisible", "()Z", isVisible) ! isVisible = (*env)->CallBooleanMethod(env, platformWindow, jm_isVisible) == JNI_TRUE ? YES : NO; ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } } return isVisible;
*** 573,587 **** // the top even if the window is not main. // We should bring up the modal dialog manually [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_checkBlockingAndOrder, jc_CPlatformWindow, ! "checkBlockingAndOrder", "()Z"); ! JNFCallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder); (*env)->DeleteLocalRef(env, platformWindow); } } return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN); --- 588,603 ---- // the top even if the window is not main. // We should bring up the modal dialog manually [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS_RETURN(NO); ! DECLARE_METHOD_RETURN(jm_checkBlockingAndOrder, jc_CPlatformWindow, "checkBlockingAndOrder", "()Z", NO); ! (*env)->CallBooleanMethod(env, platformWindow, jm_checkBlockingAndOrder); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } } return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN);
*** 601,624 **** // deliver the event if this is a user-initiated live resize or as a side-effect // of a Java initiated resize, because AppKit can override the bounds and force // the bounds of the window to avoid the Dock or remain on screen. [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow == NULL) { // TODO: create generic AWT assert } NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); ! static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V"); ! JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent, (jint)frame.origin.x, (jint)frame.origin.y, (jint)frame.size.width, (jint)frame.size.height, (jboolean)[self.nsWindow inLiveResize]); (*env)->DeleteLocalRef(env, platformWindow); [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; } --- 617,642 ---- // deliver the event if this is a user-initiated live resize or as a side-effect // of a Java initiated resize, because AppKit can override the bounds and force // the bounds of the window to avoid the Dock or remain on screen. [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow == NULL) { // TODO: create generic AWT assert } NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]); ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V"); ! (*env)->CallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent, (jint)frame.origin.x, (jint)frame.origin.y, (jint)frame.size.width, (jint)frame.size.height, (jboolean)[self.nsWindow inLiveResize]); + CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; }
*** 677,704 **** - (void) _deliverIconify:(BOOL)iconify { AWT_ASSERT_APPKIT_THREAD; [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V"); ! JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify); (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowWillMiniaturize:(NSNotification *)notification { AWT_ASSERT_APPKIT_THREAD; self.isMinimizing = YES; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V"); ! JNFCallVoidMethod(env, platformWindow, jm_windowWillMiniaturize); (*env)->DeleteLocalRef(env, platformWindow); } // Explicitly make myself a key window to avoid possible // negative visual effects during iconify operation [self.nsWindow makeKeyAndOrderFront:self.nsWindow]; --- 695,726 ---- - (void) _deliverIconify:(BOOL)iconify { AWT_ASSERT_APPKIT_THREAD; [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V"); ! (*env)->CallVoidMethod(env, platformWindow, jm_deliverIconify, iconify); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowWillMiniaturize:(NSNotification *)notification { AWT_ASSERT_APPKIT_THREAD; self.isMinimizing = YES; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_windowWillMiniaturize, jc_CPlatformWindow, "windowWillMiniaturize", "()V"); ! (*env)->CallVoidMethod(env, platformWindow, jm_windowWillMiniaturize); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } // Explicitly make myself a key window to avoid possible // negative visual effects during iconify operation [self.nsWindow makeKeyAndOrderFront:self.nsWindow];
*** 720,735 **** } - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite { //AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env]; ! ! static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V"); ! JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow); (*env)->DeleteLocalRef(env, platformWindow); (*env)->DeleteLocalRef(env, oppositeWindow); } } --- 742,758 ---- } - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite { //AWT_ASSERT_APPKIT_THREAD; JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! jobject oppositeWindow = (*env)->NewLocalRef(env, opposite.javaPlatformWindow); ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V"); ! (*env)->CallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); (*env)->DeleteLocalRef(env, oppositeWindow); } }
*** 743,756 **** if (![self.nsWindow isKeyWindow]) { [self activateWindowMenuBar]; } JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V"); ! JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain); (*env)->DeleteLocalRef(env, platformWindow); } } - (void) windowDidBecomeKey: (NSNotification *) notification { --- 766,781 ---- if (![self.nsWindow isKeyWindow]) { [self activateWindowMenuBar]; } JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V"); ! (*env)->CallVoidMethod(env, platformWindow, jm_windowDidBecomeMain); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } } - (void) windowDidBecomeKey: (NSNotification *) notification {
*** 851,927 **** - (BOOL)windowShouldClose:(id)sender { AWT_ASSERT_APPKIT_THREAD; [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V"); ! JNFCallVoidMethod(env, platformWindow, jm_deliverWindowClosingEvent); (*env)->DeleteLocalRef(env, platformWindow); } // The window will be closed (if allowed) as result of sending Java event return NO; } - - (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env { ! static JNF_CLASS_CACHE(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler"); ! static JNF_STATIC_MEMBER_CACHE(jm_notifyFullScreenOperation, jc_FullScreenHandler, "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V"); ! static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target); if (awtWindow != NULL) { ! JNFCallStaticVoidMethod(env, jm_notifyFullScreenOperation, awtWindow, op); (*env)->DeleteLocalRef(env, awtWindow); } (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowWillEnterFullScreen:(NSNotification *)notification { - static JNF_MEMBER_CACHE(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! JNFCallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowDidEnterFullScreen:(NSNotification *)notification { - static JNF_MEMBER_CACHE(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! JNFCallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; } - (void)windowWillExitFullScreen:(NSNotification *)notification { - static JNF_MEMBER_CACHE(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! JNFCallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowDidExitFullScreen:(NSNotification *)notification { - static JNF_MEMBER_CACHE(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! JNFCallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; } --- 876,969 ---- - (BOOL)windowShouldClose:(id)sender { AWT_ASSERT_APPKIT_THREAD; [AWTToolkit eventCountPlusPlus]; JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS_RETURN(NO); ! DECLARE_METHOD_RETURN(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V", NO); ! (*env)->CallVoidMethod(env, platformWindow, jm_deliverWindowClosingEvent); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } // The window will be closed (if allowed) as result of sending Java event return NO; } - (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env { ! DECLARE_CLASS(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler"); ! DECLARE_STATIC_METHOD(jm_notifyFullScreenOperation, jc_FullScreenHandler, ! "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V"); ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_FIELD(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;"); ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target); if (awtWindow != NULL) { ! (*env)->CallStaticVoidMethod(env, jc_FullScreenHandler, jm_notifyFullScreenOperation, awtWindow, op); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, awtWindow); } (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowWillEnterFullScreen:(NSNotification *)notification { JNIEnv *env = [ThreadUtilities getJNIEnv]; ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V"); ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! (*env)->CallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen); ! CHECK_EXCEPTION(); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowDidEnterFullScreen:(NSNotification *)notification { JNIEnv *env = [ThreadUtilities getJNIEnv]; ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V"); ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! (*env)->CallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen); ! CHECK_EXCEPTION(); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; } - (void)windowWillExitFullScreen:(NSNotification *)notification { JNIEnv *env = [ThreadUtilities getJNIEnv]; ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V"); ! if (jm_windowWillExitFullScreen == NULL) { ! GET_CPLATFORM_WINDOW_CLASS(); ! jm_windowWillExitFullScreen = (*env)->GetMethodID(env, jc_CPlatformWindow, "windowWillExitFullScreen", "()V"); ! } ! CHECK_NULL(jm_windowWillExitFullScreen); ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! (*env)->CallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen); ! CHECK_EXCEPTION(); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } } - (void)windowDidExitFullScreen:(NSNotification *)notification { JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V"); ! (*env)->CallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen); ! CHECK_EXCEPTION(); [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env]; (*env)->DeleteLocalRef(env, platformWindow); } [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; }
*** 931,944 **** if ([self isBlocked]) { // Move parent windows to front and make sure that a child window is displayed // in front of its nearest parent. if (self.ownerWindow != nil) { JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { ! static JNF_MEMBER_CACHE(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V"); ! JNFCallVoidMethod(env,platformWindow, jm_orderAboveSiblings); (*env)->DeleteLocalRef(env, platformWindow); } } [self orderChildWindows:YES]; } --- 973,988 ---- if ([self isBlocked]) { // Move parent windows to front and make sure that a child window is displayed // in front of its nearest parent. if (self.ownerWindow != nil) { JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_orderAboveSiblings, jc_CPlatformWindow, "orderAboveSiblings", "()V"); ! (*env)->CallVoidMethod(env,platformWindow, jm_orderAboveSiblings); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } } [self orderChildWindows:YES]; }
*** 948,962 **** NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame]; // Check if the click happened in the non-client area (title bar) if (p.y >= (frame.origin.y + contentRect.size.height)) { JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env]; if (platformWindow != NULL) { // Currently, no need to deliver the whole NSEvent. ! static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); ! JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); (*env)->DeleteLocalRef(env, platformWindow); } } } } --- 992,1008 ---- NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame]; // Check if the click happened in the non-client area (title bar) if (p.y >= (frame.origin.y + contentRect.size.height)) { JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; ! jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow); if (platformWindow != NULL) { // Currently, no need to deliver the whole NSEvent. ! GET_CPLATFORM_WINDOW_CLASS(); ! DECLARE_METHOD(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V"); ! (*env)->CallVoidMethod(env, platformWindow, jm_deliverNCMouseDown); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, platformWindow); } } } }
*** 1027,1039 **** JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow (JNIEnv *env, jobject obj, jlong contentViewPtr, jlong ownerPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h) { __block AWTWindow *window = nil; ! JNF_COCOA_ENTER(env); ! JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env]; NSView *contentView = OBJC(contentViewPtr); NSRect frameRect = NSMakeRect(x, y, w, h); AWTWindow *owner = [OBJC(ownerPtr) delegate]; [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ --- 1073,1085 ---- JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow (JNIEnv *env, jobject obj, jlong contentViewPtr, jlong ownerPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h) { __block AWTWindow *window = nil; ! JNI_COCOA_ENTER(env); ! jobject platformWindow = (*env)->NewWeakGlobalRef(env, obj); NSView *contentView = OBJC(contentViewPtr); NSRect frameRect = NSMakeRect(x, y, w, h); AWTWindow *owner = [OBJC(ownerPtr) delegate]; [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
*** 1045,1055 **** // the window is released is CPlatformWindow.nativeDispose() if (window) [window.nsWindow retain]; }]; ! JNF_COCOA_EXIT(env); return ptr_to_jlong(window ? window.nsWindow : nil); } /* --- 1091,1101 ---- // the window is released is CPlatformWindow.nativeDispose() if (window) [window.nsWindow retain]; }]; ! JNI_COCOA_EXIT(env); return ptr_to_jlong(window ? window.nsWindow : nil); } /*
*** 1058,1068 **** * Signature: (JII)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStyleBits (JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ --- 1104,1114 ---- * Signature: (JII)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStyleBits (JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
*** 1106,1127 **** if (resized) { [window _deliverMoveResizeEvent]; } }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowMenuBar * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMenuBar (JNIEnv *env, jclass clazz, jlong windowPtr, jlong menuBarPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); CMenuBar *menuBar = OBJC(menuBarPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ --- 1152,1173 ---- if (resized) { [window _deliverMoveResizeEvent]; } }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowMenuBar * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMenuBar (JNIEnv *env, jclass clazz, jlong windowPtr, jlong menuBarPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); CMenuBar *menuBar = OBJC(menuBarPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
*** 1141,1151 **** if ([nsWindow isKeyWindow] || [nsWindow isMainWindow]) { [CMenuBar activate:actualMenuBar modallyDisabled:NO]; } }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeGetNSWindowInsets --- 1187,1197 ---- if ([nsWindow isKeyWindow] || [nsWindow isMainWindow]) { [CMenuBar activate:actualMenuBar modallyDisabled:NO]; } }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeGetNSWindowInsets
*** 1154,1164 **** JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets (JNIEnv *env, jclass clazz, jlong windowPtr) { jobject ret = NULL; ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); __block NSRect contentRect = NSZeroRect; __block NSRect frame = NSZeroRect; --- 1200,1210 ---- JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets (JNIEnv *env, jclass clazz, jlong windowPtr) { jobject ret = NULL; ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); __block NSRect contentRect = NSZeroRect; __block NSRect frame = NSZeroRect;
*** 1171,1185 **** jint top = (jint)(frame.size.height - contentRect.size.height); jint left = (jint)(contentRect.origin.x - frame.origin.x); jint bottom = (jint)(contentRect.origin.y - frame.origin.y); jint right = (jint)(frame.size.width - (contentRect.size.width + left)); ! static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets"); ! static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V"); ! ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right); ! JNF_COCOA_EXIT(env); return ret; } /* * Class: sun_lwawt_macosx_CPlatformWindow --- 1217,1231 ---- jint top = (jint)(frame.size.height - contentRect.size.height); jint left = (jint)(contentRect.origin.x - frame.origin.x); jint bottom = (jint)(contentRect.origin.y - frame.origin.y); jint right = (jint)(frame.size.width - (contentRect.size.width + left)); ! DECLARE_CLASS_RETURN(jc_Insets, "java/awt/Insets", NULL); ! DECLARE_METHOD_RETURN(jc_Insets_ctor, jc_Insets, "<init>", "(IIII)V", NULL); ! ret = (*env)->NewObject(env, jc_Insets, jc_Insets_ctor, top, left, bottom, right); ! JNI_COCOA_EXIT(env); return ret; } /* * Class: sun_lwawt_macosx_CPlatformWindow
*** 1187,1197 **** * Signature: (JDDDD)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height) { ! JNF_COCOA_ENTER(env); NSRect jrect = NSMakeRect(originX, originY, width, height); // TODO: not sure we need displayIfNeeded message in our view NSWindow *nsWindow = OBJC(windowPtr); --- 1233,1243 ---- * Signature: (JDDDD)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height) { ! JNI_COCOA_ENTER(env); NSRect jrect = NSMakeRect(originX, originY, width, height); // TODO: not sure we need displayIfNeeded message in our view NSWindow *nsWindow = OBJC(windowPtr);
*** 1221,1231 **** if (!NSEqualRects(rect, [nsWindow frame])) { [window _deliverMoveResizeEvent]; } }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowStandardFrame --- 1267,1277 ---- if (!NSEqualRects(rect, [nsWindow frame])) { [window _deliverMoveResizeEvent]; } }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowStandardFrame
*** 1233,1243 **** */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStandardFrame (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height) { ! JNF_COCOA_ENTER(env); NSRect jrect = NSMakeRect(originX, originY, width, height); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ --- 1279,1289 ---- */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStandardFrame (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height) { ! JNI_COCOA_ENTER(env); NSRect jrect = NSMakeRect(originX, originY, width, height); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
*** 1245,1266 **** NSRect rect = ConvertNSScreenRect(NULL, jrect); AWTWindow *window = (AWTWindow*)[nsWindow delegate]; window.standardFrame = rect; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowLocationByPlatform * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowLocationByPlatform (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ if (NSEqualPoints(lastTopLeftPoint, NSZeroPoint)) { --- 1291,1312 ---- NSRect rect = ConvertNSScreenRect(NULL, jrect); AWTWindow *window = (AWTWindow*)[nsWindow delegate]; window.standardFrame = rect; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowLocationByPlatform * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowLocationByPlatform (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ if (NSEqualPoints(lastTopLeftPoint, NSZeroPoint)) {
*** 1270,1291 **** lastTopLeftPoint = [nsWindow cascadeTopLeftFromPoint:lastTopLeftPoint]; } lastTopLeftPoint = [nsWindow cascadeTopLeftFromPoint:lastTopLeftPoint]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowMinMax * Signature: (JDDDD)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH) { ! JNF_COCOA_ENTER(env); if (minW < 1) minW = 1; if (minH < 1) minH = 1; if (maxW < 1) maxW = 1; if (maxH < 1) maxH = 1; --- 1316,1337 ---- lastTopLeftPoint = [nsWindow cascadeTopLeftFromPoint:lastTopLeftPoint]; } lastTopLeftPoint = [nsWindow cascadeTopLeftFromPoint:lastTopLeftPoint]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowMinMax * Signature: (JDDDD)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax (JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH) { ! JNI_COCOA_ENTER(env); if (minW < 1) minW = 1; if (minH < 1) minH = 1; if (maxW < 1) maxW = 1; if (maxH < 1) maxH = 1;
*** 1304,1325 **** window.javaMinSize = min; window.javaMaxSize = max; [window updateMinMaxSize:IS(window.styleBits, RESIZABLE)]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativePushNSWindowToBack * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToBack (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow orderBack:nil]; // Order parent windows --- 1350,1371 ---- window.javaMinSize = min; window.javaMaxSize = max; [window updateMinMaxSize:IS(window.styleBits, RESIZABLE)]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativePushNSWindowToBack * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToBack (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow orderBack:nil]; // Order parent windows
*** 1332,1353 **** } // Order child windows [(AWTWindow*)[nsWindow delegate] orderChildWindows:NO]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativePushNSWindowToFront * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToFront (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ if (![nsWindow isKeyWindow]) { --- 1378,1399 ---- } // Order child windows [(AWTWindow*)[nsWindow delegate] orderChildWindows:NO]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativePushNSWindowToFront * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToFront (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ if (![nsWindow isKeyWindow]) {
*** 1355,1401 **** } else { [nsWindow orderFront:nsWindow]; } }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowTitle * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowTitle (JNIEnv *env, jclass clazz, jlong windowPtr, jstring jtitle) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [nsWindow performSelectorOnMainThread:@selector(setTitle:) ! withObject:JNFJavaToNSString(env, jtitle) waitUntilDone:NO]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeRevalidateNSWindowShadow * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeRevalidateNSWindowShadow (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow invalidateShadow]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeScreenOn_AppKitThread --- 1401,1447 ---- } else { [nsWindow orderFront:nsWindow]; } }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowTitle * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowTitle (JNIEnv *env, jclass clazz, jlong windowPtr, jstring jtitle) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [nsWindow performSelectorOnMainThread:@selector(setTitle:) ! withObject:JavaStringToNSString(env, jtitle) waitUntilDone:NO]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeRevalidateNSWindowShadow * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeRevalidateNSWindowShadow (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow invalidateShadow]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeScreenOn_AppKitThread
*** 1404,1421 **** JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeScreenOn_1AppKitThread (JNIEnv *env, jclass clazz, jlong windowPtr) { jint ret = 0; ! JNF_COCOA_ENTER(env); AWT_ASSERT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); NSDictionary *props = [[nsWindow screen] deviceDescription]; ret = [[props objectForKey:@"NSScreenNumber"] intValue]; ! JNF_COCOA_EXIT(env); return ret; } /* --- 1450,1467 ---- JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeScreenOn_1AppKitThread (JNIEnv *env, jclass clazz, jlong windowPtr) { jint ret = 0; ! JNI_COCOA_ENTER(env); AWT_ASSERT_APPKIT_THREAD; NSWindow *nsWindow = OBJC(windowPtr); NSDictionary *props = [[nsWindow screen] deviceDescription]; ret = [[props objectForKey:@"NSScreenNumber"] intValue]; ! JNI_COCOA_EXIT(env); return ret; } /*
*** 1424,1461 **** * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinimizedIcon (JNIEnv *env, jclass clazz, jlong windowPtr, jlong nsImagePtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); NSImage *image = OBJC(nsImagePtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow setMiniwindowImage:image]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowRepresentedFilename * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowRepresentedFilename (JNIEnv *env, jclass clazz, jlong windowPtr, jstring filename) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); ! NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)]; [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow setRepresentedURL:url]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeGetTopmostPlatformWindowUnderMouse --- 1470,1507 ---- * Signature: (JJ)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinimizedIcon (JNIEnv *env, jclass clazz, jlong windowPtr, jlong nsImagePtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); NSImage *image = OBJC(nsImagePtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow setMiniwindowImage:image]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSetNSWindowRepresentedFilename * Signature: (JLjava/lang/String;)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowRepresentedFilename (JNIEnv *env, jclass clazz, jlong windowPtr, jstring filename) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); ! NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:NormalizedPathNSStringFromJavaString(env, filename)]; [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow setRepresentedURL:url]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeGetTopmostPlatformWindowUnderMouse
*** 1465,1484 **** JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse (JNIEnv *env, jclass clazz) { __block jobject topmostWindowUnderMouse = nil; ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^{ AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse]; if (awtWindow != nil) { ! topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject]; } }]; ! JNF_COCOA_EXIT(env); return topmostWindowUnderMouse; } /* --- 1511,1530 ---- JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse (JNIEnv *env, jclass clazz) { __block jobject topmostWindowUnderMouse = nil; ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^{ AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse]; if (awtWindow != nil) { ! topmostWindowUnderMouse = awtWindow.javaPlatformWindow; } }]; ! JNI_COCOA_EXIT(env); return topmostWindowUnderMouse; } /*
*** 1487,1568 **** * Signature: ()V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__ (JNIEnv *env, jclass clazz) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSynthesizeMouseEnteredExitedEvents * Signature: (JI)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__JI (JNIEnv *env, jclass clazz, jlong windowPtr, jint eventType) { ! JNF_COCOA_ENTER(env); if (eventType == NSMouseEntered || eventType == NSMouseExited) { NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [AWTWindow synthesizeMouseEnteredExitedEvents:nsWindow withType:eventType]; }]; } else { ! [JNFException raise:env as:kIllegalArgumentException reason:"unknown event type"]; } ! JNF_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: _toggleFullScreenMode * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow__1toggleFullScreenMode (JNIEnv *env, jobject peer, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); SEL toggleFullScreenSelector = @selector(toggleFullScreen:); if (![nsWindow respondsToSelector:toggleFullScreenSelector]) return; [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow performSelector:toggleFullScreenSelector withObject:nil]; }]; ! JNF_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetEnabled (JNIEnv *env, jclass clazz, jlong windowPtr, jboolean isEnabled) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; [window setEnabled: isEnabled]; }]; ! JNF_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeDispose (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; --- 1533,1614 ---- * Signature: ()V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__ (JNIEnv *env, jclass clazz) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativeSynthesizeMouseEnteredExitedEvents * Signature: (JI)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents__JI (JNIEnv *env, jclass clazz, jlong windowPtr, jint eventType) { ! JNI_COCOA_ENTER(env); if (eventType == NSMouseEntered || eventType == NSMouseExited) { NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [AWTWindow synthesizeMouseEnteredExitedEvents:nsWindow withType:eventType]; }]; } else { ! JNU_ThrowIllegalArgumentException(env, "unknown event type"); } ! JNI_COCOA_EXIT(env); } /* * Class: sun_lwawt_macosx_CPlatformWindow * Method: _toggleFullScreenMode * Signature: (J)V */ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow__1toggleFullScreenMode (JNIEnv *env, jobject peer, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); SEL toggleFullScreenSelector = @selector(toggleFullScreen:); if (![nsWindow respondsToSelector:toggleFullScreenSelector]) return; [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [nsWindow performSelector:toggleFullScreenSelector withObject:nil]; }]; ! JNI_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetEnabled (JNIEnv *env, jclass clazz, jlong windowPtr, jboolean isEnabled) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; [window setEnabled: isEnabled]; }]; ! JNI_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeDispose (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate];
*** 1577,1593 **** [nsWindow setDelegate: nil]; [window release]; }]; ! JNF_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeEnterFullScreenMode (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; NSNumber* screenID = [AWTWindow getNSWindowDisplayID_AppKitThread: nsWindow]; --- 1623,1639 ---- [nsWindow setDelegate: nil]; [window release]; }]; ! JNI_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeEnterFullScreenMode (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; NSNumber* screenID = [AWTWindow getNSWindowDisplayID_AppKitThread: nsWindow];
*** 1603,1625 **** [nsWindow setLevel: shieldLevel]; NSRect screenRect = [[nsWindow screen] frame]; [nsWindow setFrame:screenRect display:YES]; } else { ! [JNFException raise:[ThreadUtilities getJNIEnv] ! as:kRuntimeException ! reason:"Failed to enter full screen."]; } }]; ! JNF_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeExitFullScreenMode (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNF_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; NSNumber* screenID = [AWTWindow getNSWindowDisplayID_AppKitThread: nsWindow]; --- 1649,1669 ---- [nsWindow setLevel: shieldLevel]; NSRect screenRect = [[nsWindow screen] frame]; [nsWindow setFrame:screenRect display:YES]; } else { ! [NSException raise:@"Java Exception" reason:@"Failed to enter full screen." userInfo:nil]; } }]; ! JNI_COCOA_EXIT(env); } JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeExitFullScreenMode (JNIEnv *env, jclass clazz, jlong windowPtr) { ! JNI_COCOA_ENTER(env); NSWindow *nsWindow = OBJC(windowPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ AWTWindow *window = (AWTWindow*)[nsWindow delegate]; NSNumber* screenID = [AWTWindow getNSWindowDisplayID_AppKitThread: nsWindow];
*** 1630,1643 **** [nsWindow setStyleMask:styleMask]; [nsWindow setLevel: window.preFullScreenLevel]; // GraphicsDevice takes care of restoring pre full screen bounds } else { ! [JNFException raise:[ThreadUtilities getJNIEnv] ! as:kRuntimeException ! reason:"Failed to exit full screen."]; } }]; ! JNF_COCOA_EXIT(env); } --- 1674,1685 ---- [nsWindow setStyleMask:styleMask]; [nsWindow setLevel: window.preFullScreenLevel]; // GraphicsDevice takes care of restoring pre full screen bounds } else { ! [NSException raise:@"Java Exception" reason:@"Failed to exit full screen." userInfo:nil]; } }]; ! JNI_COCOA_EXIT(env); }
< prev index next >