src/java.desktop/macosx/classes/sun/lwawt/LWWindowPeer.java
Print this page
*** 59,68 ****
--- 59,69 ----
private static final int MINIMUM_WIDTH = 1;
private static final int MINIMUM_HEIGHT = 1;
private Insets insets = new Insets(0, 0, 0, 0);
+ private Rectangle maximizedBounds;
private GraphicsDevice graphicsDevice;
private GraphicsConfiguration graphicsConfig;
private SurfaceData surfaceData;
*** 174,185 ****
void initializeImpl() {
super.initializeImpl();
if (getTarget() instanceof Frame) {
! setTitle(((Frame) getTarget()).getTitle());
! setState(((Frame) getTarget()).getExtendedState());
} else if (getTarget() instanceof Dialog) {
setTitle(((Dialog) getTarget()).getTitle());
}
updateAlwaysOnTopState();
--- 175,188 ----
void initializeImpl() {
super.initializeImpl();
if (getTarget() instanceof Frame) {
! Frame frame = (Frame) getTarget();
! setTitle(frame.getTitle());
! setState(frame.getExtendedState());
! setMaximizedBounds(frame.getMaximizedBounds());
} else if (getTarget() instanceof Dialog) {
setTitle(((Dialog) getTarget()).getTitle());
}
updateAlwaysOnTopState();
*** 541,553 ****
@Override
public int getState() {
return windowState;
}
@Override
public void setMaximizedBounds(Rectangle bounds) {
! // TODO: not implemented
}
@Override
public void setBoundsPrivate(int x, int y, int width, int height) {
setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);
--- 544,587 ----
@Override
public int getState() {
return windowState;
}
+ private boolean isMaximizedBoundsSet() {
+ synchronized (getStateLock()) {
+ return maximizedBounds != null;
+ }
+ }
+
+ private Rectangle getDefaultMaximizedBounds() {
+ GraphicsConfiguration config = getGraphicsConfiguration();
+ Insets screenInsets = ((CGraphicsDevice) config.getDevice())
+ .getScreenInsets();
+ Rectangle gcBounds = config.getBounds();
+ return new Rectangle(
+ gcBounds.x + screenInsets.left,
+ gcBounds.y + screenInsets.top,
+ gcBounds.width - screenInsets.left - screenInsets.right,
+ gcBounds.height - screenInsets.top - screenInsets.bottom);
+ }
+
@Override
public void setMaximizedBounds(Rectangle bounds) {
! boolean isMaximizedBoundsSet;
! synchronized (getStateLock()) {
! this.maximizedBounds = (isMaximizedBoundsSet = (bounds != null))
! ? constrainBounds(bounds) : null;
! }
!
! setPlatformMaximizedBounds(isMaximizedBoundsSet ? maximizedBounds
! : getDefaultMaximizedBounds());
! }
!
! private void setPlatformMaximizedBounds(Rectangle bounds) {
! platformWindow.setMaximizedBounds(
! bounds.x, bounds.y,
! bounds.width, bounds.height);
}
@Override
public void setBoundsPrivate(int x, int y, int width, int height) {
setBounds(x, y, width, height, SET_BOUNDS | NO_EMBEDDED_CHECK);
*** 633,642 ****
--- 667,680 ----
// First, update peer's bounds
setBounds(x, y, w, h, SET_BOUNDS, false, false);
// Second, update the graphics config and surface data
final boolean isNewDevice = updateGraphicsDevice();
+ if (isNewDevice && !isMaximizedBoundsSet()) {
+ setPlatformMaximizedBounds(getDefaultMaximizedBounds());
+ }
+
if (resized || isNewDevice) {
replaceSurfaceData();
updateMinimumSize();
}
*** 1055,1064 ****
--- 1093,1105 ----
@Override
public final void displayChanged() {
if (updateGraphicsDevice()) {
updateMinimumSize();
+ if (!isMaximizedBoundsSet()) {
+ setPlatformMaximizedBounds(getDefaultMaximizedBounds());
+ }
}
// Replace surface unconditionally, because internal state of the
// GraphicsDevice could be changed.
replaceSurfaceData();
repaintPeer();