mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
Merge branch 'master' into feat/refactor-plugin-system
This commit is contained in:
25
src/index.ts
25
src/index.ts
@ -280,31 +280,42 @@ async function createMainWindow() {
|
||||
|
||||
await loadAllMainPlugins(win);
|
||||
|
||||
|
||||
if (windowPosition) {
|
||||
const { x: windowX, y: windowY } = windowPosition;
|
||||
const winSize = win.getSize();
|
||||
const displaySize = screen.getDisplayNearestPoint(windowPosition).bounds;
|
||||
const display = screen.getDisplayNearestPoint(windowPosition);
|
||||
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 (
|
||||
windowX + winSize[0] < displaySize.x - 8 ||
|
||||
windowX - winSize[0] > displaySize.x + displaySize.width ||
|
||||
windowY < displaySize.y - 8 ||
|
||||
windowY > displaySize.y + displaySize.height
|
||||
scaledX + scaledWidth < display.bounds.x - 8 ||
|
||||
scaledX - scaledWidth > display.bounds.x + display.bounds.width ||
|
||||
scaledY < display.bounds.y - 8 ||
|
||||
scaledY > display.bounds.y + display.bounds.height
|
||||
) {
|
||||
// Window is offscreen
|
||||
if (is.dev()) {
|
||||
console.log(
|
||||
`Window tried to render offscreen, windowSize=${String(
|
||||
winSize,
|
||||
)}, displaySize=${String(displaySize)}, position=${String(
|
||||
)}, displaySize=${String(display.bounds)}, position=${String(
|
||||
windowPosition,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
win.setPosition(windowX, windowY);
|
||||
win.setSize(scaledWidth, scaledHeight);
|
||||
win.setPosition(scaledX, scaledY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (windowMaximized) {
|
||||
win.maximize();
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ import registerCallback, { type SongInfoCallback, type SongInfo } from '@/provid
|
||||
import type { DiscordPluginConfig } from './index';
|
||||
|
||||
|
||||
// Application ID registered by @Zo-Bro-23
|
||||
const clientId = '1043858434585526382';
|
||||
// Application ID registered by @th-ch/youtube-music dev team
|
||||
const clientId = '1177081335727267940';
|
||||
|
||||
export interface Info {
|
||||
rpc: DiscordClient;
|
||||
|
||||
Reference in New Issue
Block a user