diff --git a/src/main/java/org/cryptomator/common/settings/Settings.java b/src/main/java/org/cryptomator/common/settings/Settings.java index fd9f01904..4e0e0df97 100644 --- a/src/main/java/org/cryptomator/common/settings/Settings.java +++ b/src/main/java/org/cryptomator/common/settings/Settings.java @@ -65,7 +65,6 @@ public class Settings { public final IntegerProperty windowYPosition; public final IntegerProperty windowWidth; public final IntegerProperty windowHeight; - public final StringProperty displayConfiguration; public final StringProperty language; public final StringProperty mountService; public final StringProperty lastUpdateCheck; @@ -103,7 +102,6 @@ public class Settings { this.windowYPosition = new SimpleIntegerProperty(this, "windowYPosition", json.windowYPosition); this.windowWidth = new SimpleIntegerProperty(this, "windowWidth", json.windowWidth); this.windowHeight = new SimpleIntegerProperty(this, "windowHeight", json.windowHeight); - this.displayConfiguration = new SimpleStringProperty(this, "displayConfiguration", json.displayConfiguration); this.language = new SimpleStringProperty(this, "language", json.language); this.mountService = new SimpleStringProperty(this, "mountService", json.mountService); this.lastUpdateCheck = new SimpleStringProperty(this, "lastUpdateCheck", json.lastUpdateCheck); @@ -131,7 +129,6 @@ public class Settings { windowYPosition.addListener(this::somethingChanged); windowWidth.addListener(this::somethingChanged); windowHeight.addListener(this::somethingChanged); - displayConfiguration.addListener(this::somethingChanged); language.addListener(this::somethingChanged); mountService.addListener(this::somethingChanged); lastUpdateCheck.addListener(this::somethingChanged); @@ -186,7 +183,6 @@ public class Settings { json.windowYPosition = windowYPosition.get(); json.windowWidth = windowWidth.get(); json.windowHeight = windowHeight.get(); - json.displayConfiguration = displayConfiguration.get(); json.language = language.get(); json.mountService = mountService.get(); json.lastUpdateCheck = lastUpdateCheck.get(); diff --git a/src/main/java/org/cryptomator/common/settings/SettingsJson.java b/src/main/java/org/cryptomator/common/settings/SettingsJson.java index 977e1d3cd..2c7c963da 100644 --- a/src/main/java/org/cryptomator/common/settings/SettingsJson.java +++ b/src/main/java/org/cryptomator/common/settings/SettingsJson.java @@ -31,9 +31,6 @@ class SettingsJson { @JsonProperty("theme") UiTheme theme = Settings.DEFAULT_THEME; - @JsonProperty("displayConfiguration") - String displayConfiguration; - @JsonProperty("keychainProvider") String keychainProvider = Settings.DEFAULT_KEYCHAIN_PROVIDER; diff --git a/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java b/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java index 8afcdc153..9cda85cdb 100644 --- a/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java +++ b/src/main/java/org/cryptomator/ui/mainwindow/ResizeController.java @@ -6,7 +6,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.inject.Inject; -import javafx.beans.binding.Bindings; import javafx.beans.binding.BooleanBinding; import javafx.collections.ObservableList; import javafx.fxml.FXML; @@ -54,42 +53,20 @@ public class ResizeController implements FxController { public void initialize() { LOG.trace("init ResizeController"); - if (neverTouched()) { - settings.displayConfiguration.set(getMonitorSizes()); - return; - } else { - if (didDisplayConfigurationChange() || !isWithinDisplayBounds()) { - // If the position is illegal, then the window appears on the main screen in the middle of the window. - Rectangle2D primaryScreenBounds = Screen.getPrimary().getBounds(); - window.setX((primaryScreenBounds.getWidth() - window.getMinWidth()) / 2); - window.setY((primaryScreenBounds.getHeight() - window.getMinHeight()) / 2); - window.setWidth(window.getMinWidth()); - window.setHeight(window.getMinHeight()); - } else { - window.setHeight(settings.windowHeight.get() > window.getMinHeight() ? settings.windowHeight.get() : window.getMinHeight()); - window.setWidth(settings.windowWidth.get() > window.getMinWidth() ? settings.windowWidth.get() : window.getMinWidth()); - window.setX(settings.windowXPosition.get()); - window.setY(settings.windowYPosition.get()); - } + if (!neverTouched()) { + window.setHeight(settings.windowHeight.get() > window.getMinHeight() ? settings.windowHeight.get() : window.getMinHeight()); + window.setWidth(settings.windowWidth.get() > window.getMinWidth() ? settings.windowWidth.get() : window.getMinWidth()); + window.setX(settings.windowXPosition.get()); + window.setY(settings.windowYPosition.get()); } window.setOnShowing(this::checkDisplayBounds); - - savePositionalSettings(); } private boolean neverTouched() { return (settings.windowHeight.get() == 0) && (settings.windowWidth.get() == 0) && (settings.windowXPosition.get() == 0) && (settings.windowYPosition.get() == 0); } - private boolean didDisplayConfigurationChange() { - String currentDisplayConfiguration = getMonitorSizes(); - String settingsDisplayConfiguration = settings.displayConfiguration.get(); - boolean configurationHasChanged = !settingsDisplayConfiguration.equals(currentDisplayConfiguration); - if (configurationHasChanged) settings.displayConfiguration.set(currentDisplayConfiguration); - return configurationHasChanged; - } - private boolean isWithinDisplayBounds() { // (x1, y1) is the top left corner of the window, (x2, y2) is the bottom right corner final double slack = 10; @@ -131,17 +108,6 @@ public class ResizeController implements FxController { } } - private String getMonitorSizes() { - ObservableList screens = Screen.getScreens(); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < screens.size(); i++) { - Rectangle2D screenBounds = screens.get(i).getBounds(); - if (!sb.isEmpty()) sb.append(" "); - sb.append("displayId: " + i + ", " + screenBounds.getWidth() + "x" + screenBounds.getHeight() + ";"); - } - return sb.toString(); - } - private void startResize(MouseEvent evt) { origX = window.getX(); origY = window.getY();