add display to state, add display exists check
This commit is contained in:
parent
69f14ee611
commit
7dcf6a153c
2 changed files with 5 additions and 2 deletions
|
@ -12,6 +12,7 @@ import {
|
|||
Menu,
|
||||
MenuItemConstructorOptions,
|
||||
nativeTheme,
|
||||
screen,
|
||||
Tray
|
||||
} from "electron";
|
||||
import { rm } from "fs/promises";
|
||||
|
@ -269,7 +270,7 @@ function getWindowBoundsOptions(): BrowserWindowConstructorOptions {
|
|||
height: height ?? DEFAULT_HEIGHT
|
||||
} as BrowserWindowConstructorOptions;
|
||||
|
||||
if (x != null && y != null) {
|
||||
if (x != null && y != null && State.store.display && screen.getAllDisplays().includes(State.store.display)) {
|
||||
options.x = x;
|
||||
options.y = y;
|
||||
}
|
||||
|
@ -317,6 +318,7 @@ function initWindowBoundsListeners(win: BrowserWindow) {
|
|||
|
||||
const saveBounds = () => {
|
||||
State.store.windowBounds = win.getBounds();
|
||||
State.store.display = screen.getDisplayMatching(State.store.windowBounds);
|
||||
};
|
||||
|
||||
win.on("resize", saveBounds);
|
||||
|
|
3
src/shared/settings.d.ts
vendored
3
src/shared/settings.d.ts
vendored
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||
*/
|
||||
|
||||
import type { Rectangle } from "electron";
|
||||
import type { Display, Rectangle } from "electron";
|
||||
|
||||
export interface Settings {
|
||||
discordBranch?: "stable" | "canary" | "ptb";
|
||||
|
@ -36,6 +36,7 @@ export interface State {
|
|||
maximized?: boolean;
|
||||
minimized?: boolean;
|
||||
windowBounds?: Rectangle;
|
||||
display?: Display;
|
||||
|
||||
skippedUpdate?: string;
|
||||
firstLaunch?: boolean;
|
||||
|
|
Reference in a new issue