--- old/src/macosx/native/sun/awt/AWTWindow.m 2014-04-15 16:17:45.000000000 +0400 +++ new/src/macosx/native/sun/awt/AWTWindow.m 2014-04-15 16:17:45.000000000 +0400 @@ -123,6 +123,7 @@ @synthesize isEnabled; @synthesize ownerWindow; @synthesize preFullScreenLevel; +@synthesize javaMaximizedBounds = _javaMaximizedBounds; - (void) updateMinMaxSize:(BOOL)resizable { if (resizable) { @@ -251,6 +252,7 @@ self.styleBits = bits; self.ownerWindow = owner; [self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)]; + self.javaMaximizedBounds = NSMakeRect(-1, -1, -1, -1); return self; } @@ -766,6 +768,41 @@ return !NSEqualSizes(self.nsWindow.frame.size, newFrame.size); } +- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)newFrame { + CGFloat newWidth; + if (self.javaMaximizedBounds.size.width < 0) { + newWidth = newFrame.size.width; + } else { + newWidth = self.javaMaximizedBounds.size.width; + if (newWidth < self.javaMinSize.width) { + newWidth = self.javaMinSize.width; + } + if (newWidth > self.javaMaxSize.width) { + newWidth = self.javaMaxSize.width; + } + } + + CGFloat newHeight; + if (self.javaMaximizedBounds.size.height < 0) { + newHeight = newFrame.size.height; + } else { + newHeight = self.javaMaximizedBounds.size.height; + if (newHeight < self.javaMinSize.height) { + newHeight = self.javaMinSize.height; + } + if (newHeight > self.javaMaxSize.height) { + newHeight = self.javaMaxSize.height; + } + } + + newFrame.size = NSMakeSize(newWidth, newHeight); + newFrame.origin = NSMakePoint(self.javaMaximizedBounds.origin.x < 0 ? newFrame.origin.x + : self.javaMaximizedBounds.origin.x, + self.javaMaximizedBounds.origin.y < 0 ? newFrame.origin.y + : self.javaMaximizedBounds.origin.y); + return newFrame; +} + @end // AWTWindow @@ -979,6 +1016,31 @@ } /* + * + * Class: sun_lwawt_macosx_CPlatformWindow + * Method: nativeSetMaximizedBounds + * Signature: (JIIII)V + */ +JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetMaximizedBounds +(JNIEnv *env, jclass clazz, jlong windowPtr, jint x, jint y, jint w, jint h) +{ + JNF_COCOA_ENTER(env); + + NSWindow *nsWindow = OBJC(windowPtr); + [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ + AWTWindow *window = (AWTWindow*)[nsWindow delegate]; + NSRect rect = NSMakeRect(x, y, w, h); + if (y >= 0) { + rect = ConvertNSScreenRect([ThreadUtilities getJNIEnv], rect); + } + window.javaMaximizedBounds = rect; + }]; + + JNF_COCOA_EXIT(env); +} + + +/* * Class: sun_lwawt_macosx_CPlatformWindow * Method: nativePushNSWindowToBack * Signature: (J)V