diff --git a/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java b/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java index 4213c0c7c..36ec62bfc 100644 --- a/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java +++ b/app/src/main/java/io/xpipe/app/beacon/impl/AskpassExchangeImpl.java @@ -1,5 +1,7 @@ package io.xpipe.app.beacon.impl; +import io.xpipe.app.prefs.AppPrefs; +import io.xpipe.app.prefs.ExternalApplicationType; import io.xpipe.app.terminal.TerminalView; import io.xpipe.app.util.AskpassAlert; import io.xpipe.app.util.SecretManager; @@ -8,6 +10,7 @@ import io.xpipe.beacon.BeaconClientException; import io.xpipe.beacon.api.AskpassExchange; import com.sun.net.httpserver.HttpExchange; +import io.xpipe.core.process.OsType; public class AskpassExchangeImpl extends AskpassExchange { @@ -58,9 +61,17 @@ public class AskpassExchangeImpl extends AskpassExchange { } var control = term.get().controllable(); - control.ifPresent(controllableTerminalSession -> { - controllableTerminalSession.focus(); - }); + if (control.isPresent()) { + control.get().focus(); + } else { + if (OsType.getLocal() == OsType.MACOS) { + // Just focus the app, this is correct most of the time + var terminalType = AppPrefs.get().terminalType().getValue(); + if (terminalType instanceof ExternalApplicationType.MacApplication m) { + m.focus(); + } + } + } } @Override diff --git a/app/src/main/java/io/xpipe/app/comp/base/ErrorOverlayComp.java b/app/src/main/java/io/xpipe/app/comp/base/ErrorOverlayComp.java deleted file mode 100644 index 10170e689..000000000 --- a/app/src/main/java/io/xpipe/app/comp/base/ErrorOverlayComp.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.xpipe.app.comp.base; - -import io.xpipe.app.comp.Comp; -import io.xpipe.app.comp.SimpleComp; -import io.xpipe.app.util.LabelGraphic; -import io.xpipe.app.util.PlatformThread; - -import javafx.beans.property.Property; -import javafx.beans.property.SimpleObjectProperty; -import javafx.scene.control.TextArea; -import javafx.scene.layout.Region; -import javafx.scene.layout.StackPane; -import javafx.scene.paint.Color; - -import lombok.AccessLevel; -import lombok.experimental.FieldDefaults; -import org.kordamp.ikonli.javafx.FontIcon; - -@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) -public class ErrorOverlayComp extends SimpleComp { - - Comp background; - Property text; - - public ErrorOverlayComp(Comp background, Property text) { - this.background = background; - this.text = text; - } - - @Override - protected Region createSimple() { - var content = new SimpleObjectProperty(); - this.text.addListener((observable, oldValue, newValue) -> { - PlatformThread.runLaterIfNeeded(() -> { - var comp = Comp.of(() -> { - var l = new TextArea(); - l.textProperty().bind(PlatformThread.sync(text)); - l.setWrapText(true); - l.getStyleClass().add("error-overlay-comp"); - l.setEditable(false); - return l; - }); - var overlay = ModalOverlay.of("error", comp, new LabelGraphic.NodeGraphic(() -> { - var graphic = new FontIcon("mdomz-warning"); - graphic.setIconColor(Color.RED); - return new StackPane(graphic); - })) - .withDefaultButtons(); - content.set(overlay); - }); - }); - content.addListener((observable, oldValue, newValue) -> { - // Handle close - if (newValue == null) { - this.text.setValue(null); - } - }); - return new ModalOverlayComp(background, content).createRegion(); - } -} diff --git a/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java b/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java index c2303f0d4..bfa2e4789 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/ModalOverlayComp.java @@ -219,8 +219,8 @@ public class ModalOverlayComp extends SimpleComp { modalBox.setMinHeight(100); modalBox.prefWidthProperty().bind(modalBoxWidth(pane, r)); modalBox.maxWidthProperty().bind(modalBox.prefWidthProperty()); - modalBox.prefHeightProperty().bind(modalBoxHeight(pane, content)); - modalBox.maxHeightProperty().bind(modalBox.prefHeightProperty()); + modalBox.prefHeightProperty().bind(modalBoxHeight(pane, modalBox, content)); + modalBox.setMaxHeight(Region.USE_PREF_SIZE); modalBox.focusedProperty().addListener((o, old, n) -> { if (n) { content.requestFocus(); @@ -251,7 +251,7 @@ public class ModalOverlayComp extends SimpleComp { r.prefWidthProperty()); } - private ObservableDoubleValue modalBoxHeight(ModalPane pane, Region content) { + private ObservableDoubleValue modalBoxHeight(ModalPane pane, ModalBox box, Region content) { return Bindings.createDoubleBinding( () -> { var max = pane.getHeight() - 50; @@ -263,8 +263,12 @@ public class ModalOverlayComp extends SimpleComp { }, pane.heightProperty(), pane.prefHeightProperty(), + box.heightProperty(), + box.prefHeightProperty(), + box.maxHeightProperty(), content.prefHeightProperty(), - content.heightProperty()); + content.heightProperty(), + content.maxHeightProperty()); } private Button toButton(ModalButton mb) { diff --git a/app/src/main/java/io/xpipe/app/comp/base/TitledPaneComp.java b/app/src/main/java/io/xpipe/app/comp/base/TitledPaneComp.java index 2768acd3c..0d9879026 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/TitledPaneComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/TitledPaneComp.java @@ -7,6 +7,8 @@ import io.xpipe.app.comp.SimpleCompStructure; import javafx.beans.value.ObservableValue; import javafx.scene.control.TitledPane; +import java.util.concurrent.atomic.AtomicInteger; + public class TitledPaneComp extends Comp> { private final ObservableValue name; @@ -26,6 +28,17 @@ public class TitledPaneComp extends Comp> { tp.getStyleClass().add("titled-pane-comp"); tp.setExpanded(false); tp.setAnimated(false); + AtomicInteger minimizedSize = new AtomicInteger(); + tp.expandedProperty().addListener((c, o, n) -> { + if (n) { + if (minimizedSize.get() == 0) { + minimizedSize.set((int) tp.getHeight()); + } + tp.setPrefHeight(height); + } else { + tp.setPrefHeight(minimizedSize.get()); + } + }); return new SimpleCompStructure<>(tp); } } diff --git a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java index 90949598d..888e3ed63 100644 --- a/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java +++ b/app/src/main/java/io/xpipe/app/issue/ErrorHandlerComp.java @@ -158,8 +158,8 @@ public class ErrorHandlerComp extends SimpleComp { content.setFillWidth(true); content.setMinHeight(Region.USE_PREF_SIZE); - var layout = new BorderPane(); - layout.setCenter(content); + var layout = new VBox(); + layout.getChildren().add(content); layout.getStyleClass().add("error-handler-comp"); layout.getStyleClass().add("background"); @@ -167,7 +167,8 @@ public class ErrorHandlerComp extends SimpleComp { content.getChildren().add(new Separator(Orientation.HORIZONTAL)); var details = createDetails(); AppFont.medium(details); - layout.setBottom(details); + layout.getChildren().add(details); + layout.prefHeightProperty().bind(content.heightProperty().add(65).add(details.prefHeightProperty())); } return layout; diff --git a/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java b/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java index 92586eca7..2e9d29110 100644 --- a/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java +++ b/app/src/main/java/io/xpipe/app/prefs/ExternalApplicationType.java @@ -56,6 +56,14 @@ public abstract class ExternalApplicationType implements PrefsChoiceValue { } } + public void focus() { + try (ShellControl pc = LocalShell.getShell().start()) { + pc.command(String.format("open -a \"%s.app\"", applicationName)).execute(); + } catch (Exception e) { + ErrorEvent.fromThrowable(e).handle(); + } + } + @Override public boolean isSelectable() { return OsType.getLocal().equals(OsType.MACOS); diff --git a/version b/version index 8b25a2dba..e02733255 100644 --- a/version +++ b/version @@ -1 +1 @@ -14.0-21 +14.0-22