diff --git a/src/share/classes/java/awt/Frame.java b/src/share/classes/java/awt/Frame.java index 211cc3283c0b63a8529ad6b6aa66422136277f49..bd2539f055bd7a12ac8f28e589e2506d32929ea4 100644 --- a/src/share/classes/java/awt/Frame.java +++ b/src/share/classes/java/awt/Frame.java @@ -828,6 +828,11 @@ public class Frame extends Window implements MenuContainer { return frame.state; } } + public Rectangle getMaximizedBounds(Frame frame) { + synchronized(frame.getObjectLock()) { + return frame.maximizedBounds; + } + } } ); } @@ -855,8 +860,10 @@ public class Frame extends Window implements MenuContainer { * @see #getMaximizedBounds() * @since 1.4 */ - public synchronized void setMaximizedBounds(Rectangle bounds) { - this.maximizedBounds = bounds; + public void setMaximizedBounds(Rectangle bounds) { + synchronized(getObjectLock()) { + this.maximizedBounds = bounds; + } FramePeer peer = (FramePeer)this.peer; if (peer != null) { peer.setMaximizedBounds(bounds); @@ -873,7 +880,9 @@ public class Frame extends Window implements MenuContainer { * @since 1.4 */ public Rectangle getMaximizedBounds() { - return maximizedBounds; + synchronized(getObjectLock()) { + return maximizedBounds; + } } diff --git a/src/share/classes/sun/awt/AWTAccessor.java b/src/share/classes/sun/awt/AWTAccessor.java index b9171ce9798eb7c133ec15175c70a5c520d1543b..c6ec551baecdec8b550a99d8630c1c1d23c163c6 100644 --- a/src/share/classes/sun/awt/AWTAccessor.java +++ b/src/share/classes/sun/awt/AWTAccessor.java @@ -334,6 +334,10 @@ public final class AWTAccessor { * Gets the state of this frame. */ int getExtendedState(Frame frame); + /* + * Gets the maximized bounds of this frame. + */ + Rectangle getMaximizedBounds(Frame frame); } /* diff --git a/src/windows/classes/sun/awt/windows/WFramePeer.java b/src/windows/classes/sun/awt/windows/WFramePeer.java index f5b537c5ae5d26f50860b476831c7bd88f1b5d00..78eeaf0147ff84ab6f3903a4efdd028d5d9068e2 100644 --- a/src/windows/classes/sun/awt/windows/WFramePeer.java +++ b/src/windows/classes/sun/awt/windows/WFramePeer.java @@ -79,10 +79,50 @@ class WFramePeer extends WWindowPeer implements FramePeer { if (b == null) { clearMaximizedBounds(); } else { - setMaximizedBounds(b.x, b.y, b.width, b.height); + Rectangle adjBounds = (Rectangle)b.clone(); + adjustMaximizedBounds(adjBounds); + setMaximizedBounds(adjBounds.x, adjBounds.y, adjBounds.width, adjBounds.height); } } + /** + * The incoming bounds describe the maximized size and position of the + * window on the monitor that displays the window. But the window manager + * expects that the bounds are based on the size and position of the + * primary monitor, even if the window ultimately maximizes onto a + * secondary monitor. And the window manager adjusts these values to + * compensate for differences between the primary monitor and the monitor + * that displays the window. + * The method translates the incoming bounds to the values acceptable + * by the window manager. For more details, please refer to 6699851. + */ + private void adjustMaximizedBounds(Rectangle b) { + GraphicsConfiguration currentDevGC = getGraphicsConfiguration(); + + GraphicsDevice primaryDev = GraphicsEnvironment + .getLocalGraphicsEnvironment().getDefaultScreenDevice(); + GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration(); + + if (currentDevGC != null && currentDevGC != primaryDevGC) { + Rectangle currentDevBounds = currentDevGC.getBounds(); + Rectangle primaryDevBounds = primaryDevGC.getBounds(); + + b.width -= (currentDevBounds.width - primaryDevBounds.width); + b.height -= (currentDevBounds.height - primaryDevBounds.height); + } + } + + @Override + public boolean updateGraphicsData(GraphicsConfiguration gc) { + boolean result = super.updateGraphicsData(gc); + Rectangle bounds = AWTAccessor.getFrameAccessor(). + getMaximizedBounds((Frame)target); + if (bounds != null) { + setMaximizedBounds(bounds); + } + return result; + } + @Override boolean isTargetUndecorated() { return ((Frame)target).isUndecorated();