Fixes [stage]

This commit is contained in:
crschnick
2025-04-15 21:09:15 +00:00
parent 94274d7740
commit cd33e90b86
9 changed files with 44 additions and 31 deletions
@@ -58,19 +58,7 @@ public class AskpassExchangeImpl extends AskpassExchange {
if (term.isEmpty()) {
return;
}
var control = term.get().controllable();
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();
}
}
}
TerminalView.focus(term.get());
}
@Override
@@ -6,10 +6,13 @@ import io.xpipe.app.comp.base.ButtonComp;
import io.xpipe.app.core.AppFontSizes;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.AppLayoutModel;
import io.xpipe.app.util.BooleanScope;
import io.xpipe.app.util.LicenseRequiredException;
import io.xpipe.app.util.ThreadHelper;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
@@ -47,12 +50,12 @@ public class ErrorHandlerComp extends SimpleComp {
return text;
}
private Region createActionComp(ErrorAction a) {
private Region createActionComp(ErrorAction a, BooleanProperty busy) {
var graphic = createActionButtonGraphic(a.getName(), a.getDescription());
var b = new ButtonComp(null, graphic, () -> {
takenAction.setValue(a);
ThreadHelper.runAsync(() -> {
try {
try (var ignored = new BooleanScope(busy).start()) {
var r = a.handle(event);
if (r) {
closeDialogAction.run();
@@ -62,6 +65,7 @@ public class ErrorHandlerComp extends SimpleComp {
}
});
});
b.disable(busy);
b.apply(GrowAugment.create(true, false));
return b.createRegion();
}
@@ -82,7 +86,7 @@ public class ErrorHandlerComp extends SimpleComp {
}
var descriptionField = new TextArea(desc);
descriptionField.setPrefRowCount(Math.max(5, Math.min((int) desc.lines().count() + 1, 14)));
descriptionField.setPrefRowCount(Math.max(5, Math.min((int) desc.lines().count() + 2, 14)));
descriptionField.setWrapText(true);
descriptionField.setEditable(false);
descriptionField.setPadding(Insets.EMPTY);
@@ -125,19 +129,20 @@ public class ErrorHandlerComp extends SimpleComp {
}
var custom = event.getCustomActions();
var busy = new SimpleBooleanProperty();
for (var c : custom) {
var ac = createActionComp(c);
var ac = createActionComp(c, busy);
ac.getStyleClass().addAll(BUTTON_OUTLINED, ACCENT);
actionBox.getChildren().add(ac);
}
if (event.getLink() != null) {
actionBox.getChildren().add(createActionComp(ErrorAction.openDocumentation(event.getLink())));
actionBox.getChildren().add(createActionComp(ErrorAction.openDocumentation(event.getLink()), busy));
}
var hasCustomActions = event.getCustomActions().size() > 0 || event.getLink() != null;
if (hasCustomActions) {
actionBox.getChildren().add(createActionComp(ErrorAction.ignore()));
actionBox.getChildren().add(createActionComp(ErrorAction.ignore(), busy));
}
if (actionBox.getChildren().size() > 0) {
@@ -55,7 +55,7 @@ public class AboutCategory extends AppPrefsCategory {
}
var section = new OptionsBuilder()
.addComp(Comp.vspacer(40))
.addComp(Comp.vspacer(45))
.addComp(title, null)
.addComp(Comp.vspacer(10))
.name("build")
@@ -58,7 +58,7 @@ public class LinksCategory extends AppPrefsCategory {
})
.grow(true, false),
null)
.addComp(Comp.vspacer(25))
.addComp(Comp.vspacer(40))
.buildComp();
}
@@ -236,7 +236,8 @@ public class TerminalLauncher {
// Throw if not supported
multiplexer.get().checkSupported(control);
if (TerminalMultiplexerManager.requiresNewTerminalSession(request)) {
var session = TerminalMultiplexerManager.getActiveTerminalSession(request);
if (session.isEmpty()) {
return false;
}
@@ -246,6 +247,7 @@ public class TerminalLauncher {
.launchScriptExternal(control, openCommand, initScriptConfig)
.toString();
control.command(multiplexerCommand).execute();
TerminalView.focus(session.get());
return true;
}
@@ -260,7 +262,7 @@ public class TerminalLauncher {
// Throw if not supported
multiplexer.get().checkSupported(TerminalProxyManager.getProxy().orElse(LocalShell.getShell()));
if (!TerminalMultiplexerManager.requiresNewTerminalSession(request)) {
if (TerminalMultiplexerManager.getActiveTerminalSession(request).isPresent()) {
return Optional.empty();
}
@@ -61,17 +61,18 @@ public class TerminalMultiplexerManager {
lastCheck = Instant.now();
}
public static boolean requiresNewTerminalSession(UUID requestUuid) {
public static Optional<TerminalView.TerminalSession> getActiveTerminalSession(UUID requestUuid) {
var mult = getEffectiveMultiplexer();
if (mult.isEmpty()) {
connectionHubRequests.put(requestUuid, null);
return true;
return Optional.empty();
}
var hasTerminal = TerminalView.get().getSessions().stream()
.anyMatch(shellSession -> shellSession.getTerminal().isRunning()
&& mult.get() == connectionHubRequests.get(shellSession.getRequest()));
var session = TerminalView.get().getSessions().stream()
.filter(shellSession -> shellSession.getTerminal().isRunning()
&& mult.get() == connectionHubRequests.get(shellSession.getRequest()))
.findFirst();
connectionHubRequests.put(requestUuid, mult.get());
return !hasTerminal;
return session.map(shellSession -> shellSession.getTerminal());
}
}
@@ -3,6 +3,7 @@ package io.xpipe.app.terminal;
import io.xpipe.app.core.window.NativeWinWindowControl;
import io.xpipe.app.issue.TrackEvent;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.prefs.ExternalApplicationType;
import io.xpipe.app.util.ThreadHelper;
import io.xpipe.core.process.OsType;
@@ -77,6 +78,22 @@ public class TerminalView {
this.listeners.remove(listener);
}
public static void focus(TerminalSession term) {
var control = term.controllable();
if (control.isPresent()) {
control.get().show();
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();
}
}
}
}
public synchronized void open(UUID request, long pid) {
var processHandle = ProcessHandle.of(pid);
if (processHandle.isEmpty() || !processHandle.get().isAlive()) {
@@ -1,5 +1,5 @@
.prefs-box {
-fx-padding: 0 40 0 60;
-fx-padding: 0 40 0 80;
}
.prefs-container .options-comp .name {
+1 -1
View File
@@ -1 +1 @@
16.0-43
16.0-44