Docking fixes

This commit is contained in:
crschnick
2026-02-12 04:58:59 +00:00
parent 184cfb596f
commit 6e802def4c
4 changed files with 32 additions and 21 deletions
@@ -44,6 +44,8 @@ import java.util.stream.Stream;
@Getter
public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<FileSystemStore> {
private static boolean wasTerminalDocked;
private final Property<String> filter = new SimpleStringProperty();
private final BrowserFileListModel fileList;
private final ReadOnlyObjectWrapper<FilePath> currentPath = new ReadOnlyObjectWrapper<>();
@@ -580,19 +582,24 @@ public final class BrowserFileSystemTabModel extends BrowserStoreSessionTab<File
throws Exception {
var dock = shouldLaunchSplitTerminal() && dockIfPossible;
var uuid = UUID.randomUUID();
terminalRequests.add(uuid);
if (dock
&& browserModel instanceof BrowserFullSessionModel fullSessionModel
&& !(fullSessionModel.getSplits().get(this) instanceof BrowserTerminalDockTabModel)) {
terminalRequests.add(uuid);
fullSessionModel.splitTab(this, new BrowserTerminalDockTabModel(browserModel, this, terminalRequests));
}
// If we docked once, we don't want to break it by opening new tabs in maybe still docked tabs
var preferTabs = !wasTerminalDocked && !dock;
wasTerminalDocked = wasTerminalDocked || dock;
TerminalLaunch.builder()
.entry(entry.get())
.title(name)
.directory(directory)
.command(processControl)
.request(uuid)
.preferTabs(!dock)
.preferTabs(preferTabs)
.launch();
// Restart connection as we will have to start it anyway, so we speed it up by doing it preemptively
@@ -154,20 +154,22 @@ public class TerminalDockBrowserComp extends SimpleRegionBuilder {
return;
}
var bounds = region.localToScreen(region.getBoundsInLocal());
var bounds = region.localToScene(region.getBoundsInLocal());
var p = region.getPadding();
var sx = region.getScene().getWindow().getOutputScaleX();
var sy = region.getScene().getWindow().getOutputScaleY();
var scene = region.getScene();
var windowRect = NativeWinWindowControl.MAIN_WINDOW.getBounds();
var x = windowRect.getX() + ((p.getLeft() + scene.getX()) * sx);
var y = windowRect.getY() + ((p.getTop() + scene.getY()) * sy);
var x = windowRect.getX() + ((bounds.getMinX() + p.getLeft() + scene.getX()) * sx);
var y = windowRect.getY() + ((bounds.getMinY() + p.getTop() + scene.getY()) * sy);
var w = (bounds.getWidth() * sx) - p.getRight() - p.getLeft();
var h = (bounds.getHeight() * sy) - p.getBottom() - p.getTop();
model.resizeView(
(int) Math.round(x),
(int) Math.round(y),
(int) Math.round(bounds.getWidth() * sx - p.getRight() - p.getLeft()),
(int) Math.round(bounds.getHeight() * sy - p.getBottom() - p.getTop()));
(int) Math.round(w),
(int) Math.round(h));
}
}
@@ -128,20 +128,22 @@ public class TerminalDockHubComp extends SimpleRegionBuilder {
return;
}
var bounds = region.localToScreen(region.getBoundsInLocal());
var bounds = region.localToScene(region.getBoundsInLocal());
var p = region.getPadding();
var sx = region.getScene().getWindow().getOutputScaleX();
var sy = region.getScene().getWindow().getOutputScaleY();
var scene = region.getScene();
var windowRect = NativeWinWindowControl.MAIN_WINDOW.getBounds();
var x = windowRect.getX() + ((p.getLeft() + scene.getX()) * sx);
var y = windowRect.getY() + ((p.getTop() + scene.getY()) * sy);
var x = windowRect.getX() + ((bounds.getMinX() + p.getLeft() + scene.getX()) * sx);
var y = windowRect.getY() + ((bounds.getMinY() + p.getTop() + scene.getY()) * sy);
var w = (bounds.getWidth() * sx) - p.getRight() - p.getLeft();
var h = (bounds.getHeight() * sy) - p.getBottom() - p.getTop();
model.resizeView(
(int) Math.round(x),
(int) Math.round(y),
(int) Math.round(bounds.getWidth() * sx - p.getRight() - p.getLeft()),
(int) Math.round(bounds.getHeight() * sy - p.getBottom() - p.getTop()));
(int) Math.round(w),
(int) Math.round(h));
}
}
@@ -57,7 +57,7 @@ public class TerminalDockView {
Math.abs(targetBounds.getY() - currentBounds.getY()) +
Math.abs(targetBounds.getW() - currentBounds.getW()) +
Math.abs(targetBounds.getH() - currentBounds.getH());
if (sum < 10) {
if (sum < 30) {
trackTerminal(terminal, true);
return;
}
@@ -97,16 +97,16 @@ public class TerminalDockView {
}
public synchronized boolean closeOtherTerminals(UUID request) {
var sessions = TerminalView.get().getSessions();
var tv = sessions.stream()
.filter(s -> request.equals(s.getRequest()) && s.getTerminal().isRunning())
.map(s -> s.getTerminal().controllable())
.flatMap(Optional::stream)
var others = terminalInstances.stream()
.filter(terminal -> terminal.getTerminalProcess().isAlive())
.filter(terminal -> TerminalView.get().getSessions().stream()
.noneMatch(shellSession -> shellSession.getRequest().equals(request) &&
shellSession.getTerminal().equals(terminal)))
.toList();
for (int i = 0; i < tv.size() - 1; i++) {
closeTerminal(tv.get(i));
for (ControllableTerminalSession other : others) {
closeTerminal(other);
}
return tv.size() > 1;
return others.size() > 0;
}
public synchronized void closeTerminal(ControllableTerminalSession terminal) {