From 12b7555c66bda2fcb69aec6c96ca63216c7f13f9 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Thu, 11 Feb 2016 13:17:38 +0100 Subject: [PATCH] Add fix for centering for all OS --- .../java/io/bitsquare/gui/popups/Popup.java | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/gui/src/main/java/io/bitsquare/gui/popups/Popup.java b/gui/src/main/java/io/bitsquare/gui/popups/Popup.java index 60aeb51ef0..7f0824d419 100644 --- a/gui/src/main/java/io/bitsquare/gui/popups/Popup.java +++ b/gui/src/main/java/io/bitsquare/gui/popups/Popup.java @@ -100,10 +100,8 @@ public class Popup { } public void hide() { - if (Utilities.isLinux() && owner != null && positionListener != null) { - owner.getScene().getWindow().xProperty().removeListener(positionListener); - owner.getScene().getWindow().yProperty().removeListener(positionListener); - } + owner.getScene().getWindow().xProperty().removeListener(positionListener); + owner.getScene().getWindow().yProperty().removeListener(positionListener); if (centerTime != null) centerTime.cancel(); @@ -255,22 +253,21 @@ public class Popup { MainView.blurLight(); - if (Utilities.isLinux()) { - // On Linux the owner stage does not move the child stage as it does on Mac - // So we need to apply centerPopup. Further with fast movements the handler loses - // the latest position, with a delay it fixes that. - positionListener = (observable, oldValue, newValue) -> { - if (stage != null) { - centerPopup(); - if (centerTime != null) - centerTime.cancel(); + // On Linux the owner stage does not move the child stage as it does on Mac + // So we need to apply centerPopup. Further with fast movements the handler loses + // the latest position, with a delay it fixes that. + // Also on Mac sometimes the popups are positioned outside of the main app, so keep it for all OS + positionListener = (observable, oldValue, newValue) -> { + if (stage != null) { + centerPopup(); + if (centerTime != null) + centerTime.cancel(); - centerTime = UserThread.runAfter(this::centerPopup, 3); - } - }; - owner.getScene().getWindow().xProperty().addListener(positionListener); - owner.getScene().getWindow().yProperty().addListener(positionListener); - } + centerTime = UserThread.runAfter(this::centerPopup, 3); + } + }; + owner.getScene().getWindow().xProperty().addListener(positionListener); + owner.getScene().getWindow().yProperty().addListener(positionListener); } protected void centerPopup() {