提交 56a9678e 编写于 作者: D dcherepanov

6699851: setMaximizedbounds not working properly on dual screen environment

Reviewed-by: art, anthony
上级 a079c818
......@@ -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;
}
}
......
......@@ -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);
}
/*
......
......@@ -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();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册