Mercurial > hg > jdk9-shenandoah > jdk
changeset 12689:59d798c30a59
8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
Reviewed-by: serb
author | alexsch |
---|---|
date | Wed, 19 Aug 2015 09:54:15 +0400 |
parents | 1c7b7e6e1831 |
children | 97f1c1c13164 |
files | src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java |
diffstat | 3 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java Tue Aug 18 20:42:02 2015 +0300 +++ b/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,
--- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java Tue Aug 18 20:42:02 2015 +0300 +++ b/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); } }
--- a/test/java/awt/Frame/SetMaximizedBounds/SetMaximizedBounds.java Tue Aug 18 20:42:02 2015 +0300 +++ b/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,