Skip to content

Commit 85821ca

Browse files
FlorianKirmaierkevinrushforth
authored andcommitted
8251241: macOS: iconify property doesn't change after minimize when resizable is false
Reviewed-by: kcr, arapte
1 parent b25ffc7 commit 85821ca

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

modules/javafx.graphics/src/main/native-glass/mac/GlassWindow+Java.m

+8-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ - (void)_sendJavaWindowResizeEvent:(int)type forFrame:(NSRect)frame
9494
if (self->suppressWindowResizeEvent == NO)
9595
{
9696
GET_MAIN_JENV;
97-
(*env)->CallVoidMethod(env, jWindow, jWindowNotifyResize,
98-
[self->nsWindow isZoomed]
99-
? com_sun_glass_events_WindowEvent_MAXIMIZE
100-
: type,
97+
98+
if ([self->nsWindow isMiniaturized]) {
99+
type = com_sun_glass_events_WindowEvent_MINIMIZE;
100+
} else if ([self->nsWindow isZoomed]) {
101+
type = com_sun_glass_events_WindowEvent_MAXIMIZE;
102+
}
103+
104+
(*env)->CallVoidMethod(env, jWindow, jWindowNotifyResize, type,
101105
(int)frame.size.width, (int)frame.size.height);
102106
[self _sendJavaWindowMoveToAnotherScreenEventIfNeeded];
103107
}

tests/system/src/test/java/test/robot/javafx/stage/IconifyTest.java

+28-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import test.robot.testharness.VisualTestBase;
3838

3939
import static org.junit.Assert.assertTrue;
40+
import static org.junit.Assert.assertFalse;
4041
import static test.util.Util.TIMEOUT;
4142

4243
/**
@@ -55,7 +56,7 @@ public class IconifyTest extends VisualTestBase {
5556
private Stage bottomStage;
5657
private Stage topStage;
5758

58-
public void canIconifyStage(StageStyle stageStyle) throws Exception {
59+
public void canIconifyStage(StageStyle stageStyle, boolean resizable) throws Exception {
5960
final CountDownLatch shownLatch = new CountDownLatch(2);
6061

6162
runAndWait(() -> {
@@ -72,6 +73,7 @@ public void canIconifyStage(StageStyle stageStyle) throws Exception {
7273
// Top stage, will be inconified
7374
topStage = getStage(true);
7475
topStage.initStyle(stageStyle);
76+
topStage.setResizable(resizable);
7577
Scene topScene = new Scene(new Pane(), WIDTH, HEIGHT);
7678
topScene.setFill(TOP_COLOR);
7779
topStage.setScene(topScene);
@@ -90,6 +92,7 @@ public void canIconifyStage(StageStyle stageStyle) throws Exception {
9092

9193
sleep(500);
9294
runAndWait(() -> {
95+
assertFalse(topStage.isIconified());
9396
Color color = getColor(100, 100);
9497
assertColorEquals(TOP_COLOR, color, TOLERANCE);
9598
});
@@ -100,19 +103,41 @@ public void canIconifyStage(StageStyle stageStyle) throws Exception {
100103

101104
sleep(500);
102105
runAndWait(() -> {
106+
assertTrue(topStage.isIconified());
103107
Color color = getColor(100, 100);
104108
assertColorEquals(BOTTOM_COLOR, color, TOLERANCE);
105109
});
110+
111+
runAndWait(() -> {
112+
topStage.setIconified(false);
113+
});
114+
115+
sleep(500);
116+
runAndWait(() -> {
117+
assertFalse(topStage.isIconified());
118+
Color color = getColor(100, 100);
119+
assertColorEquals(TOP_COLOR, color, TOLERANCE);
120+
});
121+
}
122+
123+
@Test(timeout = 15000)
124+
public void canIconifyDecoratedStage() throws Exception {
125+
canIconifyStage(StageStyle.DECORATED, true);
106126
}
107127

108128
@Test(timeout = 15000)
109129
public void canIconifyUndecoratedStage() throws Exception {
110-
canIconifyStage(StageStyle.UNDECORATED);
130+
canIconifyStage(StageStyle.UNDECORATED, true);
111131
}
112132

113133
@Test(timeout = 15000)
114134
public void canIconifyTransparentStage() throws Exception {
115-
canIconifyStage(StageStyle.TRANSPARENT);
135+
canIconifyStage(StageStyle.TRANSPARENT, true);
136+
}
137+
138+
@Test(timeout = 15000)
139+
public void canIconifyNonResizableStage() throws Exception {
140+
canIconifyStage(StageStyle.DECORATED, false);
116141
}
117142

118143
}

0 commit comments

Comments
 (0)