Fix terminal dock for mixed display scales

This commit is contained in:
crschnick
2026-02-11 06:14:20 +00:00
parent f14fbb5c0b
commit 0cbe0f4cc8
4 changed files with 35 additions and 12 deletions
@@ -5,6 +5,7 @@ import io.xpipe.app.comp.base.LoadingIconComp;
import io.xpipe.app.core.AppFontSizes;
import io.xpipe.app.core.AppI18n;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.platform.NativeWinWindowControl;
import io.xpipe.app.platform.PlatformThread;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.util.GlobalTimer;
@@ -157,10 +158,16 @@ public class TerminalDockBrowserComp extends SimpleRegionBuilder {
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);
model.resizeView(
(int) Math.ceil(bounds.getMinX() * sx + p.getLeft()),
(int) Math.ceil(bounds.getMinY() * sy + p.getTop()),
(int) Math.floor(bounds.getWidth() * sx - p.getRight() - p.getLeft()),
(int) Math.floor(bounds.getHeight() * sy - p.getBottom() - p.getTop()));
(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()));
}
}
@@ -3,6 +3,7 @@ package io.xpipe.app.terminal;
import io.xpipe.app.comp.SimpleRegionBuilder;
import io.xpipe.app.core.window.AppMainWindow;
import io.xpipe.app.platform.NativeWinWindowControl;
import io.xpipe.app.util.GlobalTimer;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
@@ -131,9 +132,15 @@ public class TerminalDockHubComp extends SimpleRegionBuilder {
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);
model.resizeView(
(int) Math.round(bounds.getMinX() * sx + p.getLeft()),
(int) Math.round(bounds.getMinY() * sy + p.getTop()),
(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()));
}
@@ -59,12 +59,6 @@ public class TerminalDockHubManager {
return false;
}
var primaryScreen = Screen.getPrimary();
var uniformScale = Screen.getScreens().stream().allMatch(screen -> screen.getOutputScaleX() == primaryScreen.getOutputScaleX());
if (!uniformScale) {
return false;
}
return true;
}
@@ -47,7 +47,22 @@ public class TerminalDockView {
public synchronized void updateCustomBounds() {
terminalInstances.forEach(terminal -> {
var wasCustom = terminal.isCustomBounds();
terminal.updateBoundsState();
if (wasCustom && viewBounds != null) {
var currentBounds = terminal.getLastBounds();
var targetBounds = windowBoundsFunction.apply(viewBounds);
var sum = Math.abs(targetBounds.getX() - currentBounds.getX()) +
Math.abs(targetBounds.getY() - currentBounds.getY()) +
Math.abs(targetBounds.getW() - currentBounds.getW()) +
Math.abs(targetBounds.getH() - currentBounds.getH());
if (sum < 10) {
trackTerminal(terminal, true);
return;
}
}
if (terminal.isCustomBounds()) {
terminal.disown();
}