Fixes for monitor scaling

This commit is contained in:
Alexandru Macocian
2026-06-10 18:22:49 +02:00
parent 5ef8f709a5
commit f700805504
3 changed files with 27 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
0.0.3
0.0.4
+2 -2
View File
@@ -162,8 +162,8 @@ FloatingWindow {
x: workspace.originX + (VisorService.monitorX(modelData) - workspace.bounds.minX) * workspace.layoutScale
y: workspace.originY + (VisorService.monitorY(modelData) - workspace.bounds.minY) * workspace.layoutScale
width: Math.max(96, VisorService.monitorWidth(modelData) * workspace.layoutScale)
height: Math.max(64, VisorService.monitorHeight(modelData) * workspace.layoutScale)
width: Math.max(96, VisorService.monitorLogicalWidth(modelData) * workspace.layoutScale)
height: Math.max(64, VisorService.monitorLogicalHeight(modelData) * workspace.layoutScale)
radius: Theme.radius / 1.5
color: dragArea.containsMouse ? Theme.overlayWeak : Theme.background
border.color: selected ? Theme.accent : (enabledDisplay ? Theme.border : Theme.warning)
+24 -6
View File
@@ -100,6 +100,24 @@ QtObject {
return parsed ? parsed.height : m.height;
}
function monitorTransform(m) {
return m && typeof m.transform === "number" ? m.transform : 0;
}
function monitorLogicalWidth(m) {
const scale = monitorScale(m) || 1;
const rotated = (monitorTransform(m) % 2) === 1;
const pixels = rotated ? monitorHeight(m) : monitorWidth(m);
return Math.round(pixels / scale);
}
function monitorLogicalHeight(m) {
const scale = monitorScale(m) || 1;
const rotated = (monitorTransform(m) % 2) === 1;
const pixels = rotated ? monitorWidth(m) : monitorHeight(m);
return Math.round(pixels / scale);
}
function currentModeString(m) {
const modes = Array.isArray(m.availableModes) ? m.availableModes : [];
let best = "";
@@ -207,8 +225,8 @@ QtObject {
let bestDx = snapDistance + 1;
let bestDy = snapDistance + 1;
const left = x;
const width = monitorWidth(monitor);
const height = monitorHeight(monitor);
const width = monitorLogicalWidth(monitor);
const height = monitorLogicalHeight(monitor);
const right = x + width;
const top = y;
const bottom = y + height;
@@ -218,9 +236,9 @@ QtObject {
if (other.name === name) continue;
const otherLeft = monitorX(other);
const otherRight = otherLeft + monitorWidth(other);
const otherRight = otherLeft + monitorLogicalWidth(other);
const otherTop = monitorY(other);
const otherBottom = otherTop + monitorHeight(other);
const otherBottom = otherTop + monitorLogicalHeight(other);
const xCandidates = [
{ value: otherLeft, delta: Math.abs(left - otherLeft) },
@@ -284,8 +302,8 @@ QtObject {
const y = monitorY(m);
minX = Math.min(minX, x);
minY = Math.min(minY, y);
maxX = Math.max(maxX, x + monitorWidth(m));
maxY = Math.max(maxY, y + monitorHeight(m));
maxX = Math.max(maxX, x + monitorLogicalWidth(m));
maxY = Math.max(maxY, y + monitorLogicalHeight(m));
}
return {