From a2364d6f4780f7c0f84b67594077022a7bf7e725 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 22 Jun 2023 17:49:39 +0000 Subject: [PATCH] Small macOS fixes --- app/src/main/java/io/xpipe/app/core/App.java | 2 +- app/src/main/java/io/xpipe/app/core/AppLogs.java | 2 ++ .../main/java/io/xpipe/app/util/MacOsPermissions.java | 11 +++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/xpipe/app/core/App.java b/app/src/main/java/io/xpipe/app/core/App.java index c5c2c7f1..e484c5e5 100644 --- a/app/src/main/java/io/xpipe/app/core/App.java +++ b/app/src/main/java/io/xpipe/app/core/App.java @@ -34,7 +34,7 @@ public class App extends Application { // Set dock icon explicitly on mac // This is necessary in case XPipe was started through a script as it will have no icon otherwise - if (OsType.getLocal().equals(OsType.MACOS) && AppProperties.get().isDeveloperMode() && !AppLogs.get().isWriteToFile()) { + if (OsType.getLocal().equals(OsType.MACOS) && AppProperties.get().isDeveloperMode() && AppLogs.get().isWriteToSysout()) { try { var iconUrl = Main.class.getResourceAsStream("resources/img/logo/logo_128x128.png"); if (iconUrl != null) { diff --git a/app/src/main/java/io/xpipe/app/core/AppLogs.java b/app/src/main/java/io/xpipe/app/core/AppLogs.java index fd3bd887..eee0fdae 100644 --- a/app/src/main/java/io/xpipe/app/core/AppLogs.java +++ b/app/src/main/java/io/xpipe/app/core/AppLogs.java @@ -43,6 +43,8 @@ public class AppLogs { private final PrintStream originalSysOut; private final PrintStream originalSysErr; private final Path logDir; + + @Getter private final boolean writeToSysout; @Getter diff --git a/app/src/main/java/io/xpipe/app/util/MacOsPermissions.java b/app/src/main/java/io/xpipe/app/util/MacOsPermissions.java index 6a1f4c98..36fe295f 100644 --- a/app/src/main/java/io/xpipe/app/util/MacOsPermissions.java +++ b/app/src/main/java/io/xpipe/app/util/MacOsPermissions.java @@ -17,11 +17,22 @@ public class MacOsPermissions { var state = new SimpleBooleanProperty(true); try (var pc = LocalStore.getShell().start()) { while (state.get()) { + // We can't wait in the platform thread, so just return instantly + if (Platform.isFxApplicationThread()) { + pc.osascriptCommand( + """ + tell application "System Events" to keystroke "t" + """) + .execute(); + return true; + } + var success = pc.osascriptCommand( """ tell application "System Events" to keystroke "t" """) .executeAndCheck(); + if (success) { Platform.runLater(() -> { if (alert.get() != null) {