mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix: Incorrect window size on multi-monitor scaled displays (#2302)
see discussion on th-ch#2258
This commit is contained in:
12
src/index.ts
12
src/index.ts
@ -321,9 +321,11 @@ async function createMainWindow() {
|
||||
const { x: windowX, y: windowY } = windowPosition;
|
||||
const winSize = win.getSize();
|
||||
const display = screen.getDisplayNearestPoint(windowPosition);
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
|
||||
const scaledWidth = windowSize.width;
|
||||
const scaledHeight = windowSize.height;
|
||||
const scaleFactor = is.windows() ? primaryDisplay.scaleFactor / display.scaleFactor : 1;
|
||||
const scaledWidth = Math.floor(windowSize.width * scaleFactor);
|
||||
const scaledHeight = Math.floor(windowSize.height * scaleFactor);
|
||||
|
||||
const scaledX = windowX;
|
||||
const scaledY = windowY;
|
||||
@ -339,9 +341,9 @@ async function createMainWindow() {
|
||||
console.warn(
|
||||
LoggerPrefix,
|
||||
t('main.console.window.tried-to-render-offscreen', {
|
||||
winSize: String(winSize),
|
||||
displaySize: String(display.bounds),
|
||||
windowPosition: String(windowPosition),
|
||||
windowSize: String(winSize),
|
||||
displaySize: JSON.stringify(display.bounds),
|
||||
position: JSON.stringify(windowPosition),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user