Fix positioning issue for linux, change to new version nr for network and db

This commit is contained in:
Manfred Karrer 2016-02-10 23:14:12 +01:00
parent 0c465a9ec3
commit efc365f7e3
4 changed files with 19 additions and 11 deletions

View file

@ -28,10 +28,10 @@ public class Version {
// The version nr. for the objects sent over the network. A change will break the serialization of old objects. // The version nr. for the objects sent over the network. A change will break the serialization of old objects.
// If objects are used for both network and database the network version is applied. // If objects are used for both network and database the network version is applied.
public static final long P2P_NETWORK_VERSION = 1; public static final long P2P_NETWORK_VERSION = 2;
// The version nr. of the serialized data stored to disc. A change will break the serialization of old objects. // The version nr. of the serialized data stored to disc. A change will break the serialization of old objects.
public static final long LOCAL_DB_VERSION = 1; public static final long LOCAL_DB_VERSION = 2;
// The version nr. of the current protocol. The offer holds that version. // The version nr. of the current protocol. The offer holds that version.
// A taker will check the version of the offers to see if his version is compatible. // A taker will check the version of the offers to see if his version is compatible.

View file

@ -114,7 +114,7 @@ public class Utilities {
return getOSName().contains("mac") || getOSName().contains("darwin"); return getOSName().contains("mac") || getOSName().contains("darwin");
} }
private static boolean isLinux() { public static boolean isLinux() {
return getOSName().contains("linux"); return getOSName().contains("linux");
} }

View file

@ -76,7 +76,7 @@ import static io.bitsquare.app.BitsquareEnvironment.APP_NAME_KEY;
public class BitsquareApp extends Application { public class BitsquareApp extends Application {
private static final Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(BitsquareApp.class); private static final Logger log = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(BitsquareApp.class);
public static final boolean DEV_MODE = true; public static final boolean DEV_MODE = false;
public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true; public static final boolean IS_RELEASE_VERSION = !DEV_MODE && true;
private static Environment env; private static Environment env;

View file

@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
import java.time.Duration; import java.time.Duration;
import java.util.Optional; import java.util.Optional;
import java.util.Timer;
import static io.bitsquare.gui.util.FormBuilder.addCheckBox; import static io.bitsquare.gui.util.FormBuilder.addCheckBox;
@ -72,6 +73,7 @@ public class Popup {
private String dontShowAgainId; private String dontShowAgainId;
private Preferences preferences; private Preferences preferences;
private ChangeListener<Number> positionListener; private ChangeListener<Number> positionListener;
private Timer centerTime;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -98,6 +100,14 @@ public class Popup {
} }
public void hide() { public void hide() {
if (Utilities.isLinux() && owner != null && positionListener != null) {
owner.getScene().getWindow().xProperty().removeListener(positionListener);
owner.getScene().getWindow().yProperty().removeListener(positionListener);
}
if (centerTime != null)
centerTime.cancel();
MainView.removeBlur(); MainView.removeBlur();
if (stage != null) if (stage != null)
stage.hide(); stage.hide();
@ -106,11 +116,6 @@ public class Popup {
cleanup(); cleanup();
PopupManager.isHidden(this); PopupManager.isHidden(this);
if (Utilities.isUnix()) {
owner.getScene().getWindow().xProperty().removeListener(positionListener);
owner.getScene().getWindow().yProperty().removeListener(positionListener);
}
} }
protected void cleanup() { protected void cleanup() {
@ -250,14 +255,17 @@ public class Popup {
MainView.blurLight(); MainView.blurLight();
if (Utilities.isUnix()) { if (Utilities.isLinux()) {
// On Linux the owner stage does not move the child stage as it does on Mac // 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 // So we need to apply centerPopup. Further with fast movements the handler loses
// the latest position, with a delay it fixes that. // the latest position, with a delay it fixes that.
positionListener = (observable, oldValue, newValue) -> { positionListener = (observable, oldValue, newValue) -> {
if (stage != null) { if (stage != null) {
centerPopup(); centerPopup();
UserThread.runAfter(this::centerPopup, 3); if (centerTime != null)
centerTime.cancel();
centerTime = UserThread.runAfter(this::centerPopup, 3);
} }
}; };
owner.getScene().getWindow().xProperty().addListener(positionListener); owner.getScene().getWindow().xProperty().addListener(positionListener);