Commit ec131bb 1 parent 31f2871 commit ec131bb Copy full SHA for ec131bb
File tree 3 files changed +40
-16
lines changed
src/main/java/com/sparrowwallet/sparrow
3 files changed +40
-16
lines changed Original file line number Diff line number Diff line change @@ -573,6 +573,34 @@ public static AppController newAppWindow(Stage stage) {
573
573
}
574
574
}
575
575
576
+ public static void runAfterDelay (long delay , Runnable runnable ) {
577
+ if (delay <= 0 ) {
578
+ if (Platform .isFxApplicationThread ()) {
579
+ runnable .run ();
580
+ } else {
581
+ Platform .runLater (runnable );
582
+ }
583
+ } else {
584
+ ScheduledService <Void > delayService = new ScheduledService <>() {
585
+ @ Override
586
+ protected Task <Void > createTask () {
587
+ return new Task <>() {
588
+ @ Override
589
+ protected Void call () {
590
+ return null ;
591
+ }
592
+ };
593
+ }
594
+ };
595
+ delayService .setOnSucceeded (_ -> {
596
+ delayService .cancel ();
597
+ runnable .run ();
598
+ });
599
+ delayService .setDelay (Duration .millis (delay ));
600
+ delayService .start ();
601
+ }
602
+ }
603
+
576
604
private static Image getWindowIcon () {
577
605
if (windowIcon == null ) {
578
606
windowIcon = new Image (SparrowWallet .class .getResourceAsStream ("/image/sparrow-icon.png" ));
@@ -1114,6 +1142,15 @@ public static Font getMonospaceFont() {
1114
1142
return Font .font ("Roboto Mono" , 13 );
1115
1143
}
1116
1144
1145
+ public static boolean isOnWayland () {
1146
+ if (org .controlsfx .tools .Platform .getCurrent () != org .controlsfx .tools .Platform .UNIX ) {
1147
+ return false ;
1148
+ }
1149
+
1150
+ String waylandDisplay = System .getenv ("WAYLAND_DISPLAY" );
1151
+ return waylandDisplay != null && !waylandDisplay .isEmpty ();
1152
+ }
1153
+
1117
1154
@ Subscribe
1118
1155
public void newConnection (ConnectionEvent event ) {
1119
1156
currentBlockHeight = event .getBlockHeight ();
Original file line number Diff line number Diff line change @@ -90,7 +90,8 @@ public void start(Stage stage) throws Exception {
90
90
AppController appController = AppServices .newAppWindow (stage );
91
91
92
92
final boolean showNewWallet = createNewWallet ;
93
- javafx .application .Platform .runLater (() -> {
93
+ //Delay opening new dialogs on Wayland
94
+ AppServices .runAfterDelay (AppServices .isOnWayland () ? 1000 : 0 , () -> {
94
95
if (showNewWallet ) {
95
96
appController .newWallet (null );
96
97
}
Original file line number Diff line number Diff line change @@ -113,23 +113,9 @@ protected void showGrid() {
113
113
wordEntry .getEditor ().setText (words .get (i ));
114
114
wordEntry .getEditor ().setEditable (false );
115
115
} else {
116
- ScheduledService <Void > service = new ScheduledService <>() {
117
- @ Override
118
- protected Task <Void > createTask () {
119
- return new Task <>() {
120
- @ Override
121
- protected Void call () {
122
- return null ;
123
- }
124
- };
125
- }
126
- };
127
- service .setDelay (Duration .millis (500 ));
128
- service .setOnSucceeded (event1 -> {
129
- service .cancel ();
116
+ AppServices .runAfterDelay (500 , () -> {
130
117
Platform .runLater (() -> wordEntry .getEditor ().requestFocus ());
131
118
});
132
- service .start ();
133
119
}
134
120
}
135
121
}
You can’t perform that action at this time.
0 commit comments