mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
8296972: [macos13] java/awt/Frame/MaximizedToIconified/MaximizedToIconified.java: getExtendedState() != 6 as expected.
Reviewed-by: dmarkov, honkar
This commit is contained in:
@@ -42,6 +42,7 @@ import java.awt.Toolkit;
|
||||
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;
|
||||
@@ -965,6 +966,33 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
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()) {
|
||||
@@ -986,6 +1014,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
// 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;
|
||||
@@ -993,6 +1022,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
if (prevWindowState == Frame.ICONIFIED) {
|
||||
// let's return into the normal states first
|
||||
execute(CWrapper.NSWindow::deminiaturize);
|
||||
waitForWindowState(Frame.NORMAL);
|
||||
|
||||
}
|
||||
maximize();
|
||||
break;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.awt.event.WindowStateListener;
|
||||
|
||||
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;
|
||||
@@ -77,6 +77,8 @@ public class MaximizedToIconified
|
||||
frame.setSize(200, 200);
|
||||
frame.setVisible(true);
|
||||
|
||||
lastFrameState = Frame.NORMAL;
|
||||
|
||||
robot.waitForIdle();
|
||||
|
||||
frame.addWindowStateListener(new WindowStateListener() {
|
||||
@@ -114,7 +116,12 @@ public class MaximizedToIconified
|
||||
// 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});
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user