8131339: [macosx] setMaximizedBounds() doesn't work for undecorated Frame
Reviewed-by: serb
--- 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,
--- 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);
}
}
--- 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,