[bugfix] Fix window size and scale issue when windows' scaling is not 100%.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import { appWindow, currentMonitor, availableMonitors, LogicalPosition, LogicalSize } from "@tauri-apps/api/window";
|
import { appWindow, currentMonitor, availableMonitors, PhysicalPosition, PhysicalSize } from "@tauri-apps/api/window";
|
||||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||||
import { useStore_IsBreakPoint } from "@store";
|
import { useStore_IsBreakPoint } from "@store";
|
||||||
import { useUiScaling } from "@logics_configs";
|
import { useUiScaling } from "@logics_configs";
|
||||||
@@ -12,14 +12,14 @@ export const useWindow = () => {
|
|||||||
const asyncGetWindowGeometry = async () => {
|
const asyncGetWindowGeometry = async () => {
|
||||||
try {
|
try {
|
||||||
const position = await appWindow.outerPosition();
|
const position = await appWindow.outerPosition();
|
||||||
const { x, y } = position;
|
const { x: x_pos, y: y_pos } = position;
|
||||||
|
|
||||||
const size = await appWindow.outerSize();
|
const size = await appWindow.outerSize();
|
||||||
const { width, height } = size;
|
const { width, height } = size;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x_pos: x,
|
x_pos: x_pos,
|
||||||
y_pos: y,
|
y_pos: y_pos,
|
||||||
width: width,
|
width: width,
|
||||||
height: height
|
height: height
|
||||||
};
|
};
|
||||||
@@ -78,8 +78,8 @@ export const useWindow = () => {
|
|||||||
adjustedY = monitorY + monitorHeight - adjustedHeight;
|
adjustedY = monitorY + monitorHeight - adjustedHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
await appWindow.setPosition(new LogicalPosition(adjustedX, adjustedY));
|
await appWindow.setPosition(new PhysicalPosition(adjustedX, adjustedY));
|
||||||
await appWindow.setSize(new LogicalSize(adjustedWidth, adjustedHeight));
|
await appWindow.setSize(new PhysicalSize(adjustedWidth, adjustedHeight));
|
||||||
} else {
|
} else {
|
||||||
console.error("Monitor information could not be retrieved.");
|
console.error("Monitor information could not be retrieved.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user