-
Notifications
You must be signed in to change notification settings - Fork 552
8351867: No UI changes while iconified #1733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f43bbff
Ensure a redraw is performed after windows is restored
hjohn df83df1
Merge branch 'openjdk:master' into feature/minimize-issue
hjohn b66eb6e
Add test case
hjohn 2539511
Also call entireSceneNeedsRepaint
hjohn c8d199c
Also repaint when going to maximized
hjohn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
tests/system/src/test/java/test/robot/javafx/stage/DrawAfterDeiconifyTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| /* | ||
| * Copyright (c) 2025, 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 | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. Oracle designates this | ||
| * particular file as subject to the "Classpath" exception as provided | ||
| * by Oracle in the LICENSE file that accompanied this code. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
|
|
||
| package test.robot.javafx.stage; | ||
|
|
||
| import java.util.concurrent.CountDownLatch; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import javafx.application.Platform; | ||
| import javafx.scene.Scene; | ||
| import javafx.scene.layout.Pane; | ||
| import javafx.scene.paint.Color; | ||
| import javafx.stage.Stage; | ||
| import javafx.stage.StageStyle; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Timeout; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.EnumSource; | ||
|
|
||
| import static test.util.Util.TIMEOUT; | ||
|
|
||
| import test.robot.testharness.VisualTestBase; | ||
|
|
||
| /** | ||
| * Test that scene changes made while a stage is iconified get drawn after the | ||
| * stage is de-iconified. | ||
| * | ||
| * Note: on macOS you should run these tests with the Desktop & Dock | ||
| * "Minimize windows into application icon" setting turned off. When this | ||
| * setting is turned on the OS keeps generating new NSScreen objects and the | ||
| * resulting notifications will mask the original JavaFX bug. | ||
| */ | ||
| @Timeout(value=15000, unit=TimeUnit.MILLISECONDS) | ||
| public class DrawAfterDeiconifyTest extends VisualTestBase { | ||
|
|
||
| private static final int WIDTH = 300; | ||
| private static final int HEIGHT = 300; | ||
|
|
||
| private static final Color FIRST_COLOR = Color.LIME; | ||
| private static final Color SECOND_COLOR = Color.HOTPINK; | ||
|
|
||
| private static final double TOLERANCE = 0.07; | ||
|
|
||
| private Stage stage; | ||
| private int centerX; | ||
| private int centerY; | ||
|
|
||
| public void redrawsAfterDeiconify(StageStyle stageStyle, final boolean maximized) throws Exception { | ||
| final CountDownLatch stageShownLatch = new CountDownLatch(1); | ||
|
|
||
| runAndWait(() -> { | ||
| stage = getStage(false); | ||
| stage.initStyle(stageStyle); | ||
| Scene scene = new Scene(new Pane(), WIDTH, HEIGHT); | ||
| scene.setFill(FIRST_COLOR); | ||
| stage.setScene(scene); | ||
| stage.setOnShown(e -> { | ||
| Platform.runLater(() -> { | ||
| stage.setMaximized(maximized); | ||
| centerX = (int)(stage.getX() + stage.getWidth() / 2.0); | ||
| centerY = (int)(stage.getY() + stage.getHeight() / 2.0); | ||
| stageShownLatch.countDown(); | ||
| }); | ||
| }); | ||
| stage.show(); | ||
| }); | ||
|
|
||
| Assertions.assertTrue(stageShownLatch.await(TIMEOUT, TimeUnit.MILLISECONDS), "Timeout waiting for stage to be shown"); | ||
|
|
||
| waitFirstFrame(); | ||
| runAndWait(() -> { | ||
| Color color = getColor(centerX, centerY); | ||
| assertColorEquals(FIRST_COLOR, color, TOLERANCE); | ||
| stage.setIconified(true); | ||
| }); | ||
|
|
||
| // Update the scene and then wait for a pulse to clear the pending | ||
| // paint request. | ||
| runAndWait(() -> stage.getScene().setFill(SECOND_COLOR)); | ||
| waitNextFrame(); | ||
|
|
||
| // Deiconify and verify that the scene change gets redrawn | ||
| runAndWait(() -> stage.setIconified(false)); | ||
| waitNextFrame(); | ||
| runAndWait(() -> { | ||
| Color color = getColor(centerX, centerY); | ||
| assertColorEquals(SECOND_COLOR, color, TOLERANCE); | ||
| }); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @EnumSource(names = {"DECORATED", "UNDECORATED", "TRANSPARENT"}) | ||
| public void stageRedrawsAfterDeiconify(StageStyle stageStyle) throws Exception { | ||
| redrawsAfterDeiconify(stageStyle, false); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @EnumSource(names = {"DECORATED", "UNDECORATED", "TRANSPARENT"}) | ||
| public void maximizedStageRedrawsAfterDeiconify(StageStyle stageStyle) throws Exception { | ||
| redrawsAfterDeiconify(stageStyle, true); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(github diff is confusing, this code is for
WindowEvent.RESCALEcase)I suspect this might also fix an issue that I encountered in one of my applications which uses Canvas-based text editor. After the macOS is woken up after a sleep with an external monitor attached, the text on retina looked blurred. I could not get a reproducer in time, but I think it was because while I put it to sleep, the scene got re-rendered on the external monitor going from scale 2 to scale 1, but when woken up, the scene was correctly re-rendered for retina but the canvas was not resized, requiring it to be scaled.
I'll try to test this scenario, but it may take a few days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no hurry to integrate this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, the reason I bumped the reviewer count is to let you add the issue and make sure we get the testing results for linux (which we got) and our CI run (which we did).
I may not be able to test my failing scenario before you integrate anyway. We are good to go.