# HG changeset patch # User alexsch # Date 1439963655 -14400 # Node ID 6d72f6be820216bc24be8381bce0f79b6b224bc2 # Parent 9b3927068e2ca36eb22ab6cd3ad855d2f07c02c8 8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame Reviewed-by: serb diff -r 9b3927068e2c -r 6d72f6be8202 jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Tue Aug 18 20:42:02 2015 +0300 +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Wed Aug 19 09:54:15 2015 +0400 @@ -576,6 +576,14 @@ : getDefaultMaximizedBounds()); } + public Rectangle getMaximizedBounds() { + synchronized (getStateLock()) { + return (maximizedBounds == null) + ? getDefaultMaximizedBounds() + : maximizedBounds; + } + } + private void setPlatformMaximizedBounds(Rectangle bounds) { platformWindow.setMaximizedBounds( bounds.x, bounds.y, diff -r 9b3927068e2c -r 6d72f6be8202 jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Tue Aug 18 20:42:02 2015 +0300 +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Wed Aug 19 09:54:15 2015 +0400 @@ -498,14 +498,9 @@ // to be sure that there are no setBounds requests in the queue. LWCToolkit.flushNativeSelectors(); this.normalBounds = peer.getBounds(); - - GraphicsConfiguration config = getPeer().getGraphicsConfiguration(); - Insets i = ((CGraphicsDevice)config.getDevice()).getScreenInsets(); - Rectangle toBounds = config.getBounds(); - setBounds(toBounds.x + i.left, - toBounds.y + i.top, - toBounds.width - i.left - i.right, - toBounds.height - i.top - i.bottom); + Rectangle maximizedBounds = peer.getMaximizedBounds(); + setBounds(maximizedBounds.x, maximizedBounds.y, + maximizedBounds.width, maximizedBounds.height); } } diff -r 9b3927068e2c -r 6d72f6be8202 jdk/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java --- a/jdk/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java Tue Aug 18 20:42:02 2015 +0300 +++ b/jdk/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java Wed Aug 19 09:54:15 2015 +0400 @@ -24,6 +24,7 @@ import java.awt.*; /* * @test + * @bug 8065739 8131339 * @summary When Frame.setExtendedState(Frame.MAXIMIZED_BOTH) * is called for a Frame after been called setMaximizedBounds() with * certain value, Frame bounds must equal to this value. @@ -55,12 +56,14 @@ for (GraphicsDevice gd : ge.getScreenDevices()) { for (GraphicsConfiguration gc : gd.getConfigurations()) { - testMaximizedBounds(gc); + testMaximizedBounds(gc, false); + testMaximizedBounds(gc, true); } } } - static void testMaximizedBounds(GraphicsConfiguration gc) throws Exception { + static void testMaximizedBounds(GraphicsConfiguration gc, boolean undecorated) + throws Exception { Frame frame = null; try { @@ -71,6 +74,7 @@ robot.setAutoDelay(50); frame = new Frame(); + frame.setUndecorated(undecorated); Rectangle maximizedBounds = new Rectangle( maxArea.x + maxArea.width / 6, maxArea.y + maxArea.height / 6,