From ce296fe287c51c7a50c8205bc8338610bdc40595 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 10 Mar 2023 09:23:48 +0000 Subject: [PATCH] macOS fixes --- .../api/connector/XPipeApiConnection.java | 2 +- .../io/xpipe/app/prefs/CloseBehaviour.java | 5 +-- .../app/prefs/ExternalStartupBehaviour.java | 3 +- .../io/xpipe/app/util/MacOsPermissions.java | 31 +++++++++++-------- .../io/xpipe/core/util/XPipeInstallation.java | 8 ++--- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java b/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java index d43c5ab46..7a13756af 100644 --- a/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java +++ b/api/src/main/java/io/xpipe/api/connector/XPipeApiConnection.java @@ -133,7 +133,7 @@ public final class XPipeApiConnection extends BeaconConnection { private void start() throws Exception { var installation = XPipeInstallation.getLocalDefaultInstallationBasePath(true); - BeaconServer.start(installation, XPipeDaemonMode.BACKGROUND); + BeaconServer.start(installation, XPipeDaemonMode.TRAY); } @FunctionalInterface diff --git a/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java b/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java index 732e2d882..f44f31515 100644 --- a/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java +++ b/app/src/main/java/io/xpipe/app/prefs/CloseBehaviour.java @@ -6,14 +6,11 @@ import lombok.Getter; @Getter public enum CloseBehaviour implements PrefsChoiceValue { + QUIT("app.quit", () -> { OperationMode.shutdown(false, false); }), - CONTINUE_IN_BACKGROUND("app.continueInBackground", () -> { - OperationMode.switchToAsync(OperationMode.BACKGROUND); - }), - MINIMIZE_TO_TRAY("app.minimizeToTray", () -> { OperationMode.switchToAsync(OperationMode.TRAY); }); diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalStartupBehaviour.java b/app/src/main/java/io/xpipe/app/prefs/ExternalStartupBehaviour.java index c315534e7..0911c52db 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalStartupBehaviour.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalStartupBehaviour.java @@ -9,8 +9,7 @@ import lombok.Getter; @AllArgsConstructor public enum ExternalStartupBehaviour implements PrefsChoiceValue { GUI("app.startGui", OperationMode.GUI), - TRAY("app.startInTray", OperationMode.TRAY), - BACKGROUND("app.startInBackground", OperationMode.BACKGROUND); + TRAY("app.startInTray", OperationMode.TRAY); private final String id; private final OperationMode mode; 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 8ca928096..43fe6e269 100644 --- a/app/src/main/java/io/xpipe/app/util/MacOsPermissions.java +++ b/app/src/main/java/io/xpipe/app/util/MacOsPermissions.java @@ -6,6 +6,7 @@ import io.xpipe.core.impl.LocalStore; import javafx.application.Platform; import javafx.beans.property.SimpleBooleanProperty; import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; import java.util.concurrent.atomic.AtomicReference; @@ -31,19 +32,23 @@ public class MacOsPermissions { return; } - AppWindowHelper.showAlert(a -> { - a.setAlertType(Alert.AlertType.INFORMATION); - a.setTitle(AppI18n.get("permissionsAlertTitle")); - a.setHeaderText(AppI18n.get("permissionsAlertTitleHeader")); - a.getDialogPane().setContent(AppWindowHelper.alertContentText(AppI18n.get("permissionsAlertTitleContent"))); - a.getButtonTypes().clear(); - alert.set(a); - }, null, buttonType -> { - alert.get().close(); - if (buttonType.isEmpty() || !buttonType.get().getButtonData().isDefaultButton()) { - state.set(false); - } - }); + AppWindowHelper.showAlert( + a -> { + a.setAlertType(Alert.AlertType.INFORMATION); + a.setTitle(AppI18n.get("permissionsAlertTitle")); + a.setHeaderText(AppI18n.get("permissionsAlertHeader")); + a.getDialogPane() + .setContent(AppWindowHelper.alertContentText( + AppI18n.get("permissionsAlertContent"))); + a.getButtonTypes().clear(); + a.getButtonTypes().add(ButtonType.CANCEL); + alert.set(a); + }, + null, + buttonType -> { + alert.get().close(); + state.set(false); + }); }); ThreadHelper.sleep(1000); } diff --git a/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java b/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java index 632ce2a57..d6d4a31fe 100644 --- a/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java +++ b/core/src/main/java/io/xpipe/core/util/XPipeInstallation.java @@ -246,7 +246,7 @@ public class XPipeInstallation { } else if (type.equals(OsType.LINUX)) { return FileNames.join("app", "scripts", "xpiped_debug.sh"); } else { - return FileNames.join("Content", "Resources", "scripts", "xpiped_debug.sh"); + return FileNames.join("Contents", "Resources", "scripts", "xpiped_debug.sh"); } } @@ -256,7 +256,7 @@ public class XPipeInstallation { } else if (type.equals(OsType.LINUX)) { return FileNames.join("app", "scripts", "xpiped_debug_attach.sh"); } else { - return FileNames.join("Content", "Resources", "scripts", "xpiped_debug_attach.sh"); + return FileNames.join("Contents", "Resources", "scripts", "xpiped_debug_attach.sh"); } } @@ -266,7 +266,7 @@ public class XPipeInstallation { } else if (type.equals(OsType.LINUX)) { return FileNames.join("app", "bin", "xpiped"); } else { - return FileNames.join("Content", "MacOS", "xpiped"); + return FileNames.join("Contents", "MacOS", "xpiped"); } } @@ -276,7 +276,7 @@ public class XPipeInstallation { } else if (type.equals(OsType.LINUX)) { return FileNames.join("cli", "bin", "xpipe"); } else { - return FileNames.join("Content", "MacOS", "xpipe"); + return FileNames.join("Contents", "MacOS", "xpipe"); } } }