--- old/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2014-04-15 16:17:43.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/LWWindowPeer.java 2014-04-15 16:17:43.000000000 +0400 @@ -536,7 +536,16 @@ @Override public void setMaximizedBounds(Rectangle bounds) { - // TODO: not implemented + if (bounds == null) { + platformWindow.setMaximizedBounds(-1, -1, -1, -1); + } else { + platformWindow.setMaximizedBounds( + bounds.x == Integer.MAX_VALUE ? -1 : bounds.x, + bounds.y == Integer.MAX_VALUE ? -1 : bounds.y, + bounds.width == Integer.MAX_VALUE ? -1 : bounds.width, + bounds.height == Integer.MAX_VALUE ? -1 : bounds.height + ); + } } @Override --- old/src/macosx/classes/sun/lwawt/PlatformWindow.java 2014-04-15 16:17:43.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/PlatformWindow.java 2014-04-15 16:17:43.000000000 +0400 @@ -128,6 +128,18 @@ public void setSizeConstraints(int minW, int minH, int maxW, int maxH); /** + * Set the maximized bounds to the peer. If the constraint is below zero + * system provided value is used. + * + * @param mX x coordinate of the maximized window + * @param mY y coordinate of the maximized window + * @param mW width of the maximized window + * @param mH height of the maximized window + */ + default void setMaximizedBounds(int mX, int mY, int mW, int mH) { + } + + /** * Transforms the given Graphics object according to the native * implementation traits (insets, etc.). */ --- old/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java 2014-04-15 16:17:44.000000000 +0400 +++ new/src/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java 2014-04-15 16:17:44.000000000 +0400 @@ -53,6 +53,7 @@ private static native Insets nativeGetNSWindowInsets(long nsWindowPtr); private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h); private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH); + private static native void nativeSetMaximizedBounds(long nsWindowPtr, int x, int y, int w, int h); private static native void nativePushNSWindowToBack(long nsWindowPtr); private static native void nativePushNSWindowToFront(long nsWindowPtr); private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title); @@ -687,6 +688,11 @@ } @Override + public void setMaximizedBounds(int mX, int mY, int mW, int mH) { + nativeSetMaximizedBounds(getNSWindowPtr(), mX, mY, mW, mH); + } + + @Override public boolean rejectFocusRequest(CausedFocusEvent.Cause cause) { // Cross-app activation requests are not allowed. if (cause != CausedFocusEvent.Cause.MOUSE_EVENT && --- old/src/macosx/native/sun/awt/AWTWindow.h 2014-04-15 16:17:45.000000000 +0400 +++ new/src/macosx/native/sun/awt/AWTWindow.h 2014-04-15 16:17:45.000000000 +0400 @@ -56,6 +56,7 @@ @property (nonatomic, retain) AWTWindow *ownerWindow; @property (nonatomic) NSSize javaMinSize; @property (nonatomic) NSSize javaMaxSize; +@property (nonatomic) NSRect javaMaximizedBounds; @property (nonatomic) jint styleBits; @property (nonatomic) BOOL isEnabled; @property (nonatomic) jint preFullScreenLevel; --- 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