mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
check if window.y is offscreen
This commit is contained in:
8
index.js
8
index.js
@ -122,12 +122,16 @@ 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;
|
||||||
if(x + win.getSize()[0] < 0 || x - win.getSize()[0] > electron.screen.getDisplayNearestPoint({x, y}).bounds.width) {
|
const winSize = win.getSize();
|
||||||
|
const displaySize = electron.screen.getDisplayNearestPoint(windowPosition).bounds;
|
||||||
|
if((x + winSize[0] < 0 || x -winSize[0] > displaySize.width) ||
|
||||||
|
(y < 0 || y > displaySize.height)) {
|
||||||
//Window is offscreen
|
//Window is offscreen
|
||||||
if (is.dev()) {
|
if (is.dev()) {
|
||||||
console.log(`Window tried to render offscreen, Width=${win.getSize()[0]}, nearestDisplayPointer.bounds=${electron.screen.getDisplayNearestPoint({x, y}).bounds}, position=${{x, y}}`);
|
console.log(`Window tried to render offscreen, windowSize=${winSize}, displaySize=${displaySize}, position=${windowPosition}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
win.setPosition(x, y);
|
win.setPosition(x, y);
|
||||||
|
|||||||
Reference in New Issue
Block a user