From 00c7e463b5f0685af1c1d6f3babaebf5239e9651 Mon Sep 17 00:00:00 2001 From: 0xb00bface <0xb00bface@192.168.179.2> Date: Sun, 18 Apr 2021 12:05:49 +0100 Subject: [PATCH] Only save new window coordinates, if the window stays visible --- .../src/main/java/ctbrec/ui/CamrecApplication.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/src/main/java/ctbrec/ui/CamrecApplication.java b/client/src/main/java/ctbrec/ui/CamrecApplication.java index 00280ff4..94edea00 100644 --- a/client/src/main/java/ctbrec/ui/CamrecApplication.java +++ b/client/src/main/java/ctbrec/ui/CamrecApplication.java @@ -254,8 +254,16 @@ public class CamrecApplication extends Application { Player.scene = primaryStage.getScene(); primaryStage.setX(Config.getInstance().getSettings().windowX); primaryStage.setY(Config.getInstance().getSettings().windowY); - primaryStage.xProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowX = newVal.intValue()); - primaryStage.yProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowY = newVal.intValue()); + primaryStage.xProperty().addListener((observable, oldVal, newVal) -> { + if (newVal.doubleValue() + primaryStage.getWidth() > 0) { + Config.getInstance().getSettings().windowX = newVal.intValue(); + } + }); + primaryStage.yProperty().addListener((observable, oldVal, newVal) -> { + if (newVal.doubleValue() + primaryStage.getHeight() > 0) { + Config.getInstance().getSettings().windowY = newVal.intValue(); + } + }); primaryStage.show(); primaryStage.setOnCloseRequest(createShutdownHandler()); Runtime.getRuntime().addShutdownHook(new Thread(() -> Platform.runLater(this::shutdown)));