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 @synthesize standardFrame;
188 @synthesize isMinimizing;
189
190 - (void) updateMinMaxSize:(BOOL)resizable {
191 if (resizable) {
192 [self.nsWindow setMinSize:self.javaMinSize];
193 [self.nsWindow setMaxSize:self.javaMaxSize];
194 } else {
195 NSRect currentFrame = [self.nsWindow frame];
196 [self.nsWindow setMinSize:currentFrame.size];
197 [self.nsWindow setMaxSize:currentFrame.size];
198 }
199 }
200
201 // creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits
202 + (NSUInteger) styleMaskForStyleBits:(jint)styleBits {
203 NSUInteger type = 0;
204 if (IS(styleBits, DECORATED)) {
205 type |= NSTitledWindowMask;
206 if (IS(styleBits, CLOSEABLE)) type |= NSClosableWindowMask;
207 if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
208 if (IS(styleBits, RESIZABLE)) type |= NSResizableWindowMask;
209 } else {
725 }
726
727 - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
728 //AWT_ASSERT_APPKIT_THREAD;
729 JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
730 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
731 if (platformWindow != NULL) {
732 jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
733
734 static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
735 JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
736 (*env)->DeleteLocalRef(env, platformWindow);
737 (*env)->DeleteLocalRef(env, oppositeWindow);
738 }
739 }
740
741 - (void) windowDidBecomeMain: (NSNotification *) notification {
742 AWT_ASSERT_APPKIT_THREAD;
743 [AWTToolkit eventCountPlusPlus];
744 #ifdef DEBUG
745 NSLog(@"became main: %d %@ %@", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow]);
746 #endif
747
748 if (![self.nsWindow isKeyWindow]) {
749 [self activateWindowMenuBar];
750 }
751
752 JNIEnv *env = [ThreadUtilities getJNIEnv];
753 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
754 if (platformWindow != NULL) {
755 static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
756 JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain);
757 (*env)->DeleteLocalRef(env, platformWindow);
758 }
759 }
760
761 - (void) windowDidBecomeKey: (NSNotification *) notification {
762 AWT_ASSERT_APPKIT_THREAD;
763 [AWTToolkit eventCountPlusPlus];
764 #ifdef DEBUG
765 NSLog(@"became key: %d %@ %@", [self.nsWindow isMainWindow], [self.nsWindow title], [self menuBarForWindow]);
766 #endif
767 AWTWindow *opposite = [AWTWindow lastKeyWindow];
768
769 if (![self.nsWindow isMainWindow]) {
770 [self activateWindowMenuBar];
771 }
772
773 [AWTWindow setLastKeyWindow:nil];
774
775 [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
776 [self orderChildWindows:YES];
777 }
778
779 - (void) activateWindowMenuBar {
780 AWT_ASSERT_APPKIT_THREAD;
781 // Finds appropriate menubar in our hierarchy
782 AWTWindow *awtWindow = self;
783 while (awtWindow.ownerWindow != nil) {
784 awtWindow = awtWindow.ownerWindow;
785 }
786
|
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 @synthesize standardFrame;
188 @synthesize isMinimizing;
189
190 // Key notification received status
191 static bool keyNotificationRecd = false;
192
193 - (void) updateMinMaxSize:(BOOL)resizable {
194 if (resizable) {
195 [self.nsWindow setMinSize:self.javaMinSize];
196 [self.nsWindow setMaxSize:self.javaMaxSize];
197 } else {
198 NSRect currentFrame = [self.nsWindow frame];
199 [self.nsWindow setMinSize:currentFrame.size];
200 [self.nsWindow setMaxSize:currentFrame.size];
201 }
202 }
203
204 // creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits
205 + (NSUInteger) styleMaskForStyleBits:(jint)styleBits {
206 NSUInteger type = 0;
207 if (IS(styleBits, DECORATED)) {
208 type |= NSTitledWindowMask;
209 if (IS(styleBits, CLOSEABLE)) type |= NSClosableWindowMask;
210 if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
211 if (IS(styleBits, RESIZABLE)) type |= NSResizableWindowMask;
212 } else {
728 }
729
730 - (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
731 //AWT_ASSERT_APPKIT_THREAD;
732 JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
733 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
734 if (platformWindow != NULL) {
735 jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
736
737 static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
738 JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
739 (*env)->DeleteLocalRef(env, platformWindow);
740 (*env)->DeleteLocalRef(env, oppositeWindow);
741 }
742 }
743
744 - (void) windowDidBecomeMain: (NSNotification *) notification {
745 AWT_ASSERT_APPKIT_THREAD;
746 [AWTToolkit eventCountPlusPlus];
747 #ifdef DEBUG
748 NSLog(@"became main: %d %@ %@ %d", [self.nsWindow isKeyWindow], [self.nsWindow title], [self menuBarForWindow], keyNotificationRecd);
749 #endif
750
751 // if for some reason, no KEY notification is received but this main window is also a key window
752 // then we need to execute the KEY notification functionality.
753 if(keyNotificationRecd != true && [self.nsWindow isKeyWindow]) {
754 [self doWindowDidBecomeKey];
755 }
756 keyNotificationRecd = false;
757
758 if (![self.nsWindow isKeyWindow]) {
759 [self activateWindowMenuBar];
760 }
761
762 JNIEnv *env = [ThreadUtilities getJNIEnv];
763 jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
764 if (platformWindow != NULL) {
765 static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
766 JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain);
767 (*env)->DeleteLocalRef(env, platformWindow);
768 }
769 }
770
771 - (void) windowDidBecomeKey: (NSNotification *) notification {
772 AWT_ASSERT_APPKIT_THREAD;
773 [AWTToolkit eventCountPlusPlus];
774 #ifdef DEBUG
775 NSLog(@"became key: %d %@ %@", [self.nsWindow isMainWindow], [self.nsWindow title], [self menuBarForWindow]);
776 #endif
777 [self doWindowDidBecomeKey];
778 keyNotificationRecd = true;
779 }
780
781 - (void) doWindowDidBecomeKey {
782 AWT_ASSERT_APPKIT_THREAD;
783 AWTWindow *opposite = [AWTWindow lastKeyWindow];
784
785 if (![self.nsWindow isMainWindow]) {
786 [self activateWindowMenuBar];
787 }
788
789 [AWTWindow setLastKeyWindow:nil];
790
791 [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
792 [self orderChildWindows:YES];
793 }
794
795 - (void) activateWindowMenuBar {
796 AWT_ASSERT_APPKIT_THREAD;
797 // Finds appropriate menubar in our hierarchy
798 AWTWindow *awtWindow = self;
799 while (awtWindow.ownerWindow != nil) {
800 awtWindow = awtWindow.ownerWindow;
801 }
802
|