--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java 2018-09-21 16:33:21.000000000 +0530 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java 2018-09-21 16:33:21.000000000 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -276,6 +276,8 @@ private Rectangle normalBounds = null; // not-null only for undecorated maximized windows private CPlatformResponder responder; private long lastBecomeMainTime; // this is necessary to preserve right siblings order + private boolean maximizedBothState = false; + private boolean frameResizibilityChanged = false; public CPlatformWindow() { super(0, true); @@ -378,7 +380,7 @@ // Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable { - final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false); + final boolean resizable = isTargetResizable(); styleBits = SET(styleBits, RESIZABLE, resizable); if (!resizable) { styleBits = SET(styleBits, ZOOMABLE, false); @@ -580,6 +582,8 @@ setBounds(maximizedBounds.x, maximizedBounds.y, maximizedBounds.width, maximizedBounds.height); } + setFrameResizibilityChanged(true); + updateResizableAndMaximizeState(true); } private void unmaximize() { @@ -676,11 +680,9 @@ // Manage the extended state when showing if (visible) { /* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the - Frame or Dialog is resizable. + Frame resizable and Frame state is not MAXIMIZED_BOTH or Dialog is resizable. **/ - final boolean resizable = (target instanceof Frame) ? ((Frame)target).isResizable() : - ((target instanceof Dialog) ? ((Dialog)target).isResizable() : false); - if (resizable) { + if (isTargetResizable()) { setCanFullscreen(true); } @@ -695,6 +697,12 @@ // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. frameState = Frame.ICONIFIED; } + + if (isFrameResizibilityChanged()) { + updateResizableAndMaximizeState(false); + setFrameResizibilityChanged(false); + } + switch (frameState) { case Frame.ICONIFIED: execute(CWrapper.NSWindow::miniaturize); @@ -814,9 +822,13 @@ @Override public void setResizable(final boolean resizable) { - setCanFullscreen(resizable); - setStyleBits(RESIZABLE, resizable); - setStyleBits(ZOOMABLE, resizable); + boolean windowResizable = resizable; + if (resizable && isMaximizedBoth()) { + windowResizable = false; + } + setCanFullscreen(windowResizable); + setStyleBits(RESIZABLE, windowResizable); + setStyleBits(ZOOMABLE, windowResizable); } @Override @@ -924,6 +936,12 @@ // Treat all state bit masks with ICONIFIED bit as ICONIFIED state. windowState = Frame.ICONIFIED; } + + if (isFrameResizibilityChanged()) { + updateResizableAndMaximizeState(false); + setFrameResizibilityChanged(false); + } + switch (windowState) { case Frame.ICONIFIED: if (prevWindowState == Frame.MAXIMIZED_BOTH) { @@ -1126,6 +1144,16 @@ } } + private void deliverDoubleClickOnTitlebar() { + if ((peer != null) && (target instanceof Frame)) { + if (isMaximizedBoth()) { + updateResizableAndMaximizeState(false); + execute(CWrapper.NSWindow::zoom); + updateResizableAndMaximizeState(true); + } + } + } + /* * Our focus model is synthetic and only non-simple window * may become natively focusable window. @@ -1301,6 +1329,32 @@ return false; } + private boolean isTargetResizable() { + if (target instanceof Frame) { + return ((Frame)target).isResizable() && !isMaximizedBoth(); + } else if (target instanceof Dialog) { + return ((Dialog)target).isResizable(); + } + return false; + } + + private void updateResizableAndMaximizeState(boolean maximizeState) { + maximizedBothState = maximizeState; + setResizable(!maximizeState); + } + + private boolean isMaximizedBoth() { + return maximizedBothState; + } + + private void setFrameResizibilityChanged(boolean resize) { + frameResizibilityChanged = resize; + } + + private boolean isFrameResizibilityChanged() { + return frameResizibilityChanged; + } + // ---------------------------------------------------------------------- // NATIVE CALLBACKS // ----------------------------------------------------------------------