src/macosx/native/sun/awt/AWTWindow.m
Print this page
*** 118,127 ****
--- 118,128 ----
@synthesize javaMenuBar;
@synthesize javaMinSize;
@synthesize javaMaxSize;
@synthesize styleBits;
@synthesize isEnabled;
+ @synthesize ownerWindow;
- (void) updateMinMaxSize:(BOOL)resizable {
if (resizable) {
[self.nsWindow setMinSize:self.javaMinSize];
[self.nsWindow setMaxSize:self.javaMaxSize];
*** 199,208 ****
--- 200,210 ----
}
}
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
+ ownerWindow:owner
styleBits:(jint)bits
frameRect:(NSRect)rect
contentView:(NSView *)view
{
AWT_ASSERT_APPKIT_THREAD;
*** 243,252 ****
--- 245,255 ----
[self.nsWindow release]; // the property retains the object already
self.isEnabled = YES;
self.javaPlatformWindow = platformWindow;
self.styleBits = bits;
+ self.ownerWindow = owner;
[self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
return self;
}
*** 348,358 ****
JNIEnv *env = [ThreadUtilities getJNIEnv];
[self.javaPlatformWindow setJObject:nil withEnv:env];
self.nsWindow = nil;
!
[super dealloc];
}
// NSWindow overrides
- (BOOL) canBecomeKeyWindow {
--- 351,361 ----
JNIEnv *env = [ThreadUtilities getJNIEnv];
[self.javaPlatformWindow setJObject:nil withEnv:env];
self.nsWindow = nil;
! self.ownerWindow = nil;
[super dealloc];
}
// NSWindow overrides
- (BOOL) canBecomeKeyWindow {
*** 537,551 ****
- (void) windowDidBecomeKey: (NSNotification *) notification {
AWT_ASSERT_APPKIT_THREAD;
[AWTToolkit eventCountPlusPlus];
AWTWindow *opposite = [AWTWindow lastKeyWindow];
! if (!IS(self.styleBits, IS_DIALOG)) {
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
! } else if ((opposite != NULL) && IS(self.styleBits, IS_MODAL)) {
! [CMenuBar activate:opposite->javaMenuBar modallyDisabled:YES];
}
[AWTWindow setLastKeyWindow:nil];
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
}
--- 540,569 ----
- (void) windowDidBecomeKey: (NSNotification *) notification {
AWT_ASSERT_APPKIT_THREAD;
[AWTToolkit eventCountPlusPlus];
AWTWindow *opposite = [AWTWindow lastKeyWindow];
!
! // Finds appropriate menubar in our hierarchy,
! if (self.javaMenuBar != nil || !IS(self.styleBits, IS_DIALOG)) {
! // shortpath
[CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
! } else {
! // Dialog w/o menubar
! BOOL disabled = IS(self.styleBits, IS_MODAL);
! AWTWindow *awtWindow = self;
! CMenuBar *menuBar = nil;
! while (menuBar == nil && awtWindow != nil) {
! if ([awtWindow.nsWindow isVisible]){
! menuBar = awtWindow.javaMenuBar;
! }
! disabled |= !awtWindow.isEnabled;
! awtWindow = awtWindow.ownerWindow;
}
+ [CMenuBar activate:menuBar modallyDisabled:disabled];
+ }
+
[AWTWindow setLastKeyWindow:nil];
[self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
}
*** 739,761 ****
* Class: sun_lwawt_macosx_CPlatformWindow
* Method: nativeCreateNSWindow
* Signature: (JJIIII)J
*/
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow
! (JNIEnv *env, jobject obj, jlong contentViewPtr, 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);
!
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
styleBits:styleBits
frameRect:frameRect
contentView:contentView];
// the window is released is CPlatformWindow.nativeDispose()
--- 757,780 ----
* Class: sun_lwawt_macosx_CPlatformWindow
* Method: nativeCreateNSWindow
* Signature: (JJIIII)J
*/
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:^(){
window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
+ ownerWindow:owner
styleBits:styleBits
frameRect:frameRect
contentView:contentView];
// the window is released is CPlatformWindow.nativeDispose()