mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-14 03:41:46 +00:00
Merge pull request #548 from Araxeus/offscreen-app-fix
fix app starting offscreen
This commit is contained in:
13
index.js
13
index.js
@ -127,9 +127,20 @@ function createMainWindow() {
|
|||||||
autoHideMenuBar: config.get("options.hideMenu"),
|
autoHideMenuBar: config.get("options.hideMenu"),
|
||||||
});
|
});
|
||||||
remote.enable(win.webContents);
|
remote.enable(win.webContents);
|
||||||
|
|
||||||
if (windowPosition) {
|
if (windowPosition) {
|
||||||
const { x, y } = windowPosition;
|
const { x, y } = windowPosition;
|
||||||
win.setPosition(x, y);
|
const winSize = win.getSize();
|
||||||
|
const displaySize = electron.screen.getDisplayNearestPoint(windowPosition).bounds;
|
||||||
|
if((x + winSize[0] < displaySize.x - 8 || x - winSize[0] > displaySize.x + displaySize.width) ||
|
||||||
|
(y < displaySize.y - 8 || y > displaySize.y + displaySize.height)) {
|
||||||
|
//Window is offscreen
|
||||||
|
if (is.dev()) {
|
||||||
|
console.log(`Window tried to render offscreen, windowSize=${winSize}, displaySize=${displaySize}, position=${windowPosition}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
win.setPosition(x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (windowMaximized) {
|
if (windowMaximized) {
|
||||||
win.maximize();
|
win.maximize();
|
||||||
|
|||||||
Reference in New Issue
Block a user