8215280: Double click on titlebar not working for Frame with extended state set to MAXIMIZED_BOTH
Reviewed-by: serb, kaddepalli
This commit is contained in:
parent
731e728ece
commit
61f2218ba2
src/java.desktop/macosx
test/jdk/java/awt/Frame/UnfocusableMaximizedFrameResizablity
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2019, 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
|
||||
@ -295,8 +295,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
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);
|
||||
@ -399,7 +397,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
|
||||
{
|
||||
final boolean resizable = isTargetResizable();
|
||||
final boolean resizable = isFrame ? ((Frame)target).isResizable() : (isDialog ? ((Dialog)target).isResizable() : false);
|
||||
styleBits = SET(styleBits, RESIZABLE, resizable);
|
||||
if (!resizable) {
|
||||
styleBits = SET(styleBits, ZOOMABLE, false);
|
||||
@ -611,8 +609,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
setBounds(maximizedBounds.x, maximizedBounds.y,
|
||||
maximizedBounds.width, maximizedBounds.height);
|
||||
}
|
||||
setFrameResizibilityChanged(true);
|
||||
updateResizableAndMaximizeState(true);
|
||||
}
|
||||
|
||||
private void unmaximize() {
|
||||
@ -709,9 +705,11 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
// Manage the extended state when showing
|
||||
if (visible) {
|
||||
/* Frame or Dialog should be set property WINDOW_FULLSCREENABLE to true if the
|
||||
Frame resizable and Frame state is not MAXIMIZED_BOTH or Dialog is resizable.
|
||||
Frame or Dialog is resizable.
|
||||
**/
|
||||
if (isTargetResizable()) {
|
||||
final boolean resizable = (target instanceof Frame) ? ((Frame)target).isResizable() :
|
||||
((target instanceof Dialog) ? ((Dialog)target).isResizable() : false);
|
||||
if (resizable) {
|
||||
setCanFullscreen(true);
|
||||
}
|
||||
|
||||
@ -727,11 +725,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
frameState = Frame.ICONIFIED;
|
||||
}
|
||||
|
||||
if (isFrameResizibilityChanged()) {
|
||||
updateResizableAndMaximizeState(false);
|
||||
setFrameResizibilityChanged(false);
|
||||
}
|
||||
|
||||
switch (frameState) {
|
||||
case Frame.ICONIFIED:
|
||||
execute(CWrapper.NSWindow::miniaturize);
|
||||
@ -851,10 +844,9 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
|
||||
@Override
|
||||
public void setResizable(final boolean resizable) {
|
||||
boolean windowResizable = resizable && !isMaximizedBoth();
|
||||
setCanFullscreen(windowResizable);
|
||||
setStyleBits(RESIZABLE, windowResizable);
|
||||
setStyleBits(ZOOMABLE, windowResizable);
|
||||
setCanFullscreen(resizable);
|
||||
setStyleBits(RESIZABLE, resizable);
|
||||
setStyleBits(ZOOMABLE, resizable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -963,11 +955,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
windowState = Frame.ICONIFIED;
|
||||
}
|
||||
|
||||
if (isFrameResizibilityChanged()) {
|
||||
updateResizableAndMaximizeState(false);
|
||||
setFrameResizibilityChanged(false);
|
||||
}
|
||||
|
||||
switch (windowState) {
|
||||
case Frame.ICONIFIED:
|
||||
if (prevWindowState == Frame.MAXIMIZED_BOTH) {
|
||||
@ -1170,21 +1157,6 @@ 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
|
||||
* may become natively focusable window.
|
||||
@ -1350,33 +1322,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
}
|
||||
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
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2019, 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
|
||||
@ -965,11 +965,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
// Currently, no need to deliver the whole NSEvent.
|
||||
static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, 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
|
||||
@ -24,7 +24,7 @@
|
||||
/*
|
||||
@test
|
||||
@key headful
|
||||
@bug 4980161 7158623 8204860 8208125
|
||||
@bug 4980161 7158623 8204860 8208125 8215280
|
||||
@summary Setting focusable window state to false makes the maximized frame resizable
|
||||
@compile UnfocusableMaximizedFrameResizablity.java
|
||||
@run main UnfocusableMaximizedFrameResizablity
|
||||
@ -47,8 +47,15 @@ public class UnfocusableMaximizedFrameResizablity {
|
||||
|
||||
private static void createAndShowFrame() throws Exception {
|
||||
|
||||
//MAXIMIZED_BOTH frame is resizable on Mac OS by default. Nothing to test.
|
||||
if (System.getProperty("os.name").toLowerCase().startsWith("mac")) {
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
//The MAXIMIZED_BOTH state is not supported by the toolkit. Nothing to test.
|
||||
if (!Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) {
|
||||
cleanup();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -93,7 +100,9 @@ public class UnfocusableMaximizedFrameResizablity {
|
||||
}
|
||||
|
||||
private static void cleanup() {
|
||||
frame.dispose();
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
isProgInterruption = true;
|
||||
mainThread.interrupt();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user