mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 12:26:45 +00:00
delay opening new dialogs on startup in wayland
This commit is contained in:
parent
31f287125f
commit
ec131bb8da
3 changed files with 40 additions and 16 deletions
|
@ -573,6 +573,34 @@ public class AppServices {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void runAfterDelay(long delay, Runnable runnable) {
|
||||||
|
if(delay <= 0) {
|
||||||
|
if(Platform.isFxApplicationThread()) {
|
||||||
|
runnable.run();
|
||||||
|
} else {
|
||||||
|
Platform.runLater(runnable);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ScheduledService<Void> delayService = new ScheduledService<>() {
|
||||||
|
@Override
|
||||||
|
protected Task<Void> createTask() {
|
||||||
|
return new Task<>() {
|
||||||
|
@Override
|
||||||
|
protected Void call() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
delayService.setOnSucceeded(_ -> {
|
||||||
|
delayService.cancel();
|
||||||
|
runnable.run();
|
||||||
|
});
|
||||||
|
delayService.setDelay(Duration.millis(delay));
|
||||||
|
delayService.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Image getWindowIcon() {
|
private static Image getWindowIcon() {
|
||||||
if(windowIcon == null) {
|
if(windowIcon == null) {
|
||||||
windowIcon = new Image(SparrowWallet.class.getResourceAsStream("/image/sparrow-icon.png"));
|
windowIcon = new Image(SparrowWallet.class.getResourceAsStream("/image/sparrow-icon.png"));
|
||||||
|
@ -1114,6 +1142,15 @@ public class AppServices {
|
||||||
return Font.font("Roboto Mono", 13);
|
return Font.font("Roboto Mono", 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isOnWayland() {
|
||||||
|
if(org.controlsfx.tools.Platform.getCurrent() != org.controlsfx.tools.Platform.UNIX) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String waylandDisplay = System.getenv("WAYLAND_DISPLAY");
|
||||||
|
return waylandDisplay != null && !waylandDisplay.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void newConnection(ConnectionEvent event) {
|
public void newConnection(ConnectionEvent event) {
|
||||||
currentBlockHeight = event.getBlockHeight();
|
currentBlockHeight = event.getBlockHeight();
|
||||||
|
|
|
@ -90,7 +90,8 @@ public class SparrowDesktop extends Application {
|
||||||
AppController appController = AppServices.newAppWindow(stage);
|
AppController appController = AppServices.newAppWindow(stage);
|
||||||
|
|
||||||
final boolean showNewWallet = createNewWallet;
|
final boolean showNewWallet = createNewWallet;
|
||||||
javafx.application.Platform.runLater(() -> {
|
//Delay opening new dialogs on Wayland
|
||||||
|
AppServices.runAfterDelay(AppServices.isOnWayland() ? 1000 : 0, () -> {
|
||||||
if(showNewWallet) {
|
if(showNewWallet) {
|
||||||
appController.newWallet(null);
|
appController.newWallet(null);
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,23 +113,9 @@ public class MnemonicKeystorePane extends TitledDescriptionPane {
|
||||||
wordEntry.getEditor().setText(words.get(i));
|
wordEntry.getEditor().setText(words.get(i));
|
||||||
wordEntry.getEditor().setEditable(false);
|
wordEntry.getEditor().setEditable(false);
|
||||||
} else {
|
} else {
|
||||||
ScheduledService<Void> service = new ScheduledService<>() {
|
AppServices.runAfterDelay(500, () -> {
|
||||||
@Override
|
|
||||||
protected Task<Void> createTask() {
|
|
||||||
return new Task<>() {
|
|
||||||
@Override
|
|
||||||
protected Void call() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
service.setDelay(Duration.millis(500));
|
|
||||||
service.setOnSucceeded(event1 -> {
|
|
||||||
service.cancel();
|
|
||||||
Platform.runLater(() -> wordEntry.getEditor().requestFocus());
|
Platform.runLater(() -> wordEntry.getEditor().requestFocus());
|
||||||
});
|
});
|
||||||
service.start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue