mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
Windows Zoom, ScaleFactor (#1402)
This commit is contained in:
26
src/index.ts
26
src/index.ts
@ -176,28 +176,38 @@ async function createMainWindow() {
|
|||||||
});
|
});
|
||||||
await loadPlugins(win);
|
await loadPlugins(win);
|
||||||
|
|
||||||
|
|
||||||
if (windowPosition) {
|
if (windowPosition) {
|
||||||
const { x: windowX, y: windowY } = windowPosition;
|
const { x: windowX, y: windowY } = windowPosition;
|
||||||
const winSize = win.getSize();
|
const winSize = win.getSize();
|
||||||
const displaySize
|
const display = screen.getDisplayNearestPoint(windowPosition);
|
||||||
= screen.getDisplayNearestPoint(windowPosition).bounds;
|
const scaleFactor = display.scaleFactor;
|
||||||
|
|
||||||
|
const scaledWidth = Math.floor(windowSize.width / scaleFactor);
|
||||||
|
const scaledHeight = Math.floor(windowSize.height / scaleFactor);
|
||||||
|
|
||||||
|
const scaledX = windowX;
|
||||||
|
const scaledY = windowY;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
windowX + winSize[0] < displaySize.x - 8
|
scaledX + scaledWidth < display.bounds.x - 8 ||
|
||||||
|| windowX - winSize[0] > displaySize.x + displaySize.width
|
scaledX - scaledWidth > display.bounds.x + display.bounds.width ||
|
||||||
|| windowY < displaySize.y - 8
|
scaledY < display.bounds.y - 8 ||
|
||||||
|| windowY > displaySize.y + displaySize.height
|
scaledY > display.bounds.y + display.bounds.height
|
||||||
) {
|
) {
|
||||||
// Window is offscreen
|
// Window is offscreen
|
||||||
if (is.dev()) {
|
if (is.dev()) {
|
||||||
console.log(
|
console.log(
|
||||||
`Window tried to render offscreen, windowSize=${String(winSize)}, displaySize=${String(displaySize)}, position=${String(windowPosition)}`,
|
`Window tried to render offscreen, windowSize=${String(winSize)}, displaySize=${String(display.bounds)}, position=${String(windowPosition)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
win.setPosition(windowX, windowY);
|
win.setSize(scaledWidth, scaledHeight);
|
||||||
|
win.setPosition(scaledX, scaledY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (windowMaximized) {
|
if (windowMaximized) {
|
||||||
win.maximize();
|
win.maximize();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user