Skip to content

Commit

Permalink
8296972: [macos13] java/awt/Frame/MaximizedToIconified/MaximizedToIco…
Browse files Browse the repository at this point in the history
…nified.java: getExtendedState() != 6 as expected.

Reviewed-by: dmarkov, honkar
  • Loading branch information
Alisen Chung committed Jun 28, 2023
1 parent 9f46fc2 commit f0c2f09
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.awt.Window;
import java.awt.event.FocusEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowStateListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -965,6 +966,33 @@ public boolean isFullScreenMode() {
return isFullScreenMode;
}

private void waitForWindowState(int state) {
if (peer.getState() == state) {
return;
}

Object lock = new Object();
WindowStateListener wsl = new WindowStateListener() {
public void windowStateChanged(WindowEvent e) {
synchronized (lock) {
if (e.getNewState() == state) {
lock.notifyAll();
}
}
}
};

target.addWindowStateListener(wsl);
if (peer.getState() != state) {
synchronized (lock) {
try {
lock.wait();
} catch (InterruptedException ie) {}
}
}
target.removeWindowStateListener(wsl);
}

@Override
public void setWindowState(int windowState) {
if (peer == null || !peer.isVisible()) {
Expand All @@ -986,13 +1014,16 @@ public void setWindowState(int windowState) {
// let's return into the normal states first
// the zoom call toggles between the normal and the max states
unmaximize();
waitForWindowState(Frame.NORMAL);
}
execute(CWrapper.NSWindow::miniaturize);
break;
case Frame.MAXIMIZED_BOTH:
if (prevWindowState == Frame.ICONIFIED) {
// let's return into the normal states first
execute(CWrapper.NSWindow::deminiaturize);
waitForWindowState(Frame.NORMAL);

}
maximize();
break;
Expand Down
1 change: 0 additions & 1 deletion test/jdk/ProblemList.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ java/awt/Focus/FocusOwnerFrameOnClick/FocusOwnerFrameOnClick.java 8081489 generi
java/awt/Focus/IconifiedFrameFocusChangeTest/IconifiedFrameFocusChangeTest.java 6849364 generic-all
java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusToFrontTest.java 6848406 generic-all
java/awt/Focus/AutoRequestFocusTest/AutoRequestFocusSetVisibleTest.java 6848407 generic-all
java/awt/Frame/MaximizedToIconified/MaximizedToIconified.java 8296972 macosx-all
java/awt/Frame/MaximizedUndecorated/MaximizedUndecorated.java 8022302 generic-all
java/awt/Frame/RestoreToOppositeScreen/RestoreToOppositeScreen.java 8286840 linux-all
java/awt/FileDialog/FileDialogIconTest/FileDialogIconTest.java 8160558 windows-all
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

public class MaximizedToIconified
{
static volatile int lastFrameState = Frame.NORMAL;
static volatile int lastFrameState;
static volatile boolean failed = false;
static volatile Toolkit myKit;
private static Robot robot;
Expand Down Expand Up @@ -77,6 +77,8 @@ private static void examineStates(int states[]) {
frame.setSize(200, 200);
frame.setVisible(true);

lastFrameState = Frame.NORMAL;

robot.waitForIdle();

frame.addWindowStateListener(new WindowStateListener() {
Expand Down Expand Up @@ -114,7 +116,12 @@ private static void doTest() {
// because Toolkit.isFrameStateSupported() method reports these states
// as not supported. And such states will simply be skipped.
examineStates(new int[] {Frame.MAXIMIZED_BOTH, Frame.ICONIFIED, Frame.NORMAL});
System.out.println("------");
examineStates(new int[] {Frame.ICONIFIED, Frame.MAXIMIZED_BOTH, Frame.NORMAL});
System.out.println("------");
examineStates(new int[] {Frame.NORMAL, Frame.MAXIMIZED_BOTH, Frame.ICONIFIED});
System.out.println("------");
examineStates(new int[] {Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_BOTH});

}

Expand Down

1 comment on commit f0c2f09

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.