mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-09-27 10:55:52 +00:00
Fix terminal dock for mixed display scales
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user