Resizing stage while it is maximized breaks scene size on Linux

Thiago Milczarek Sayão thiago.sayao at gmail.com
Sat Mar 29 12:24:30 UTC 2025


I did not find a bug report, so I did one and provided a fix:

https://github.com/openjdk/jfx/pull/1748



Em sáb., 29 de mar. de 2025 às 08:26, Thiago Milczarek Sayão <
thiago.sayao at gmail.com> escreveu:

> @Christopher Schnick <crschnick at xpipe.io>
>
> Hi, did you open a bug? I have a fix for this.
>
> Thanks
>
> -- Thiago.
>
> Em seg., 17 de mar. de 2025 às 09:49, Christopher Schnick <
> crschnick at xpipe.io> escreveu:
>
>> So on Windows at least, it will change the width temporarily and then
>> revert back to the original width value. So you will receive two width
>> change events if you listen to the stage width property. The maximized
>> property is not changed.
>>
>> I guess this also not optimal handling of this. Ideally, no changes would
>> be made in that case.
>> On 17/03/2025 10:53, Thiago Milczarek Sayão wrote:
>>
>> Hi Christopher,
>>
>> It seems like a simple fix.
>>
>> How does it behave on other platforms? Does it ignore the resize, restore
>> the window to its unmaximized state before resizing, or keep it maximized
>> while adjusting the unmaximized size.
>>
>> -- Thiago
>>
>>
>>
>>
>>
>>
>> Em dom., 16 de mar. de 2025 às 05:25, Christopher Schnick <
>> crschnick at xpipe.io> escreveu:
>>
>>> Hello,
>>>
>>> we encountered an issue on Linux where resizing the stage while it is
>>> maximized breaks the size of the scene. You can see a video of this at
>>> https://github.com/xpipe-io/xpipe/issues/485 . The root cause is that
>>> the stage size is modified.
>>>
>>> When doing this, it temporarily or permanently switches to the size the
>>> stage had prior to being maximized, leading to either a flicker or a
>>> permanently broken scene that has the wrong size. This happens on Gnome and
>>> KDE for me with the latest JavaFX ea version.
>>>
>>> Here is a simple reproducer:
>>>
>>> import javafx.application.Application;import javafx.scene.Scene;import javafx.scene.control.Button;import javafx.scene.layout.Region;import javafx.scene.layout.StackPane;import javafx.stage.Stage;
>>> import java.io.IOException;import java.util.Base64;
>>> public class MaximizeLinuxBug extends Application {
>>>
>>>     @Override    public void start(Stage stage) throws IOException {
>>>         Scene scene = new Scene(createContent(), 640, 480);
>>>         var s = "data:text/css;base64," + Base64.getEncoder().encodeToString(createCss().getBytes());
>>>         scene.getStylesheets().add(s);
>>>         stage.setTitle("Hello!");
>>>         stage.setScene(scene);
>>>         stage.show();
>>>         stage.centerOnScreen();
>>>         stage.setMaximized(true);
>>>     }
>>>
>>>     private String createCss() {
>>>         return """                * {                -fx-border-color: red;                -fx-border-width: 1;                }                """;
>>>     }
>>>
>>>     private Region createContent() {
>>>         var button = new Button("Click me!");
>>>         button.setOnAction(event -> {
>>>             var w = button.getScene().getWindow();
>>>             w.setWidth(w.getWidth() - 1);
>>>             event.consume();
>>>         });
>>>         var stack = new StackPane(button);
>>>         return stack;
>>>     }
>>>
>>>     public static void main(String[] args) {
>>>         launch();
>>>     }
>>> }
>>>
>>>
>>> Best
>>> Christopher Schnick
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20250329/fcf38f55/attachment.htm>


More information about the openjfx-dev mailing list