< prev index next >
src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformWindow.java
Print this page
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -274,10 +274,12 @@
protected boolean visible = false; // visibility status from native perspective
private boolean undecorated; // initialized in getInitialStyleBits()
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);
}
@@ -376,11 +378,11 @@
if (this.undecorated) styleBits = SET(styleBits, DECORATED, false);
}
// 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);
}
}
@@ -578,10 +580,12 @@
this.normalBounds = peer.getBounds();
Rectangle maximizedBounds = peer.getMaximizedBounds();
setBounds(maximizedBounds.x, maximizedBounds.y,
maximizedBounds.width, maximizedBounds.height);
}
+ setFrameResizibilityChanged(true);
+ updateResizableAndMaximizeState(true);
}
private void unmaximize() {
if (!isMaximized()) {
return;
@@ -674,15 +678,13 @@
this.visible = visible;
// 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);
}
// Apply the extended state as expected in shared code
if (target instanceof Frame) {
@@ -693,10 +695,16 @@
int frameState = ((Frame)target).getExtendedState();
if ((frameState & Frame.ICONIFIED) != 0) {
// 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);
break;
case Frame.MAXIMIZED_BOTH:
@@ -812,13 +820,14 @@
}
}
@Override
public void setResizable(final boolean resizable) {
- setCanFullscreen(resizable);
- setStyleBits(RESIZABLE, resizable);
- setStyleBits(ZOOMABLE, resizable);
+ boolean windowResizable = resizable && !isMaximizedBoth();
+ setCanFullscreen(windowResizable);
+ setStyleBits(RESIZABLE, windowResizable);
+ setStyleBits(ZOOMABLE, windowResizable);
}
@Override
public void setSizeConstraints(int minW, int minH, int maxW, int maxH) {
execute(ptr -> nativeSetNSWindowMinMax(ptr, minW, minH, maxW, maxH));
@@ -922,10 +931,16 @@
if ((windowState & Frame.ICONIFIED) != 0) {
// 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) {
// let's return into the normal states first
// the zoom call toggles between the normal and the max states
@@ -1125,10 +1140,25 @@
peer.notifyNCMouseDown();
}
}
/*
+ * Resizibility of frame with state MAXIMIZED_BOTH is set to true to zoom
+ * the frame on double click on title bar and set to false later. This is
+ * required as frame won't zoom if resizibility of frame is false.
+ */
+ 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.
*/
private boolean isNativelyFocusableWindow() {
if (peer == null) {
@@ -1299,10 +1329,36 @@
return (getOwnerFrameOrDialog(target) instanceof CEmbeddedFrame);
}
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
// ----------------------------------------------------------------------
private void windowWillMiniaturize() {
< prev index next >