8209123: [Macosx] Maximized frame (frame state set to MAXIMIZED_BOTH using setExtendedState) is resizable on Mac but not on Windows and Ubuntu
Reviewed-by: kaddepalli, psadhukhan
This commit is contained in:
parent
06c91fcf7f
commit
b114b70d35
@ -295,6 +295,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
|
private Rectangle normalBounds = null; // not-null only for undecorated maximized windows
|
||||||
private CPlatformResponder responder;
|
private CPlatformResponder responder;
|
||||||
private long lastBecomeMainTime; // this is necessary to preserve right siblings order
|
private long lastBecomeMainTime; // this is necessary to preserve right siblings order
|
||||||
|
private boolean maximizedBothState = false;
|
||||||
|
private boolean frameResizibilityChanged = false;
|
||||||
|
|
||||||
public CPlatformWindow() {
|
public CPlatformWindow() {
|
||||||
super(0, true);
|
super(0, true);
|
||||||
@ -397,7 +399,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
|
|
||||||
// Either java.awt.Frame or java.awt.Dialog can be resizable, however java.awt.Window is never resizable
|
// 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);
|
styleBits = SET(styleBits, RESIZABLE, resizable);
|
||||||
if (!resizable) {
|
if (!resizable) {
|
||||||
styleBits = SET(styleBits, ZOOMABLE, false);
|
styleBits = SET(styleBits, ZOOMABLE, false);
|
||||||
@ -609,6 +611,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
setBounds(maximizedBounds.x, maximizedBounds.y,
|
setBounds(maximizedBounds.x, maximizedBounds.y,
|
||||||
maximizedBounds.width, maximizedBounds.height);
|
maximizedBounds.width, maximizedBounds.height);
|
||||||
}
|
}
|
||||||
|
setFrameResizibilityChanged(true);
|
||||||
|
updateResizableAndMaximizeState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unmaximize() {
|
private void unmaximize() {
|
||||||
@ -705,11 +709,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
// Manage the extended state when showing
|
// Manage the extended state when showing
|
||||||
if (visible) {
|
if (visible) {
|
||||||
/* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the
|
/* 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() :
|
if (isTargetResizable()) {
|
||||||
((target instanceof Dialog) ? ((Dialog)target).isResizable() : false);
|
|
||||||
if (resizable) {
|
|
||||||
setCanFullscreen(true);
|
setCanFullscreen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,6 +726,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
// Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
|
// Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
|
||||||
frameState = Frame.ICONIFIED;
|
frameState = Frame.ICONIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isFrameResizibilityChanged()) {
|
||||||
|
updateResizableAndMaximizeState(false);
|
||||||
|
setFrameResizibilityChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
switch (frameState) {
|
switch (frameState) {
|
||||||
case Frame.ICONIFIED:
|
case Frame.ICONIFIED:
|
||||||
execute(CWrapper.NSWindow::miniaturize);
|
execute(CWrapper.NSWindow::miniaturize);
|
||||||
@ -843,9 +851,10 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setResizable(final boolean resizable) {
|
public void setResizable(final boolean resizable) {
|
||||||
setCanFullscreen(resizable);
|
boolean windowResizable = resizable && !isMaximizedBoth();
|
||||||
setStyleBits(RESIZABLE, resizable);
|
setCanFullscreen(windowResizable);
|
||||||
setStyleBits(ZOOMABLE, resizable);
|
setStyleBits(RESIZABLE, windowResizable);
|
||||||
|
setStyleBits(ZOOMABLE, windowResizable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -953,6 +962,12 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
// Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
|
// Treat all state bit masks with ICONIFIED bit as ICONIFIED state.
|
||||||
windowState = Frame.ICONIFIED;
|
windowState = Frame.ICONIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isFrameResizibilityChanged()) {
|
||||||
|
updateResizableAndMaximizeState(false);
|
||||||
|
setFrameResizibilityChanged(false);
|
||||||
|
}
|
||||||
|
|
||||||
switch (windowState) {
|
switch (windowState) {
|
||||||
case Frame.ICONIFIED:
|
case Frame.ICONIFIED:
|
||||||
if (prevWindowState == Frame.MAXIMIZED_BOTH) {
|
if (prevWindowState == Frame.MAXIMIZED_BOTH) {
|
||||||
@ -1155,6 +1170,21 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
* Our focus model is synthetic and only non-simple window
|
||||||
* may become natively focusable window.
|
* may become natively focusable window.
|
||||||
@ -1330,6 +1360,32 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
|||||||
return false;
|
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
|
// NATIVE CALLBACKS
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -965,6 +965,11 @@ AWT_ASSERT_APPKIT_THREAD;
|
|||||||
// Currently, no need to deliver the whole NSEvent.
|
// Currently, no need to deliver the whole NSEvent.
|
||||||
static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
|
static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
|
||||||
JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
|
JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
|
||||||
|
// Deliver double click on title bar
|
||||||
|
if ([event clickCount] > 1) {
|
||||||
|
static JNF_MEMBER_CACHE(jm_deliverDoubleClickOnTitlebar, jc_CPlatformWindow, "deliverDoubleClickOnTitlebar", "()V");
|
||||||
|
JNFCallVoidMethod(env, platformWindow, jm_deliverDoubleClickOnTitlebar);
|
||||||
|
}
|
||||||
(*env)->DeleteLocalRef(env, platformWindow);
|
(*env)->DeleteLocalRef(env, platformWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user