Fix window bounds issue #10

This commit is contained in:
Jean Ouina 2020-08-04 13:43:22 +02:00
parent f82bd92ff5
commit f177b331db
4 changed files with 301 additions and 286 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -243,6 +243,11 @@ export default new class V2_SettingsPanel {
if (id === "no_window_bound"){
let appSettings = remote.getGlobal("appSettings")
appSettings.set("NO_WINDOWS_BOUND", enabled)
appSettings.delete("IS_MAXIMIZED")
appSettings.delete("IS_MINIMIZED")
appSettings.delete("WINDOW_BOUNDS")
appSettings.save()
remote.app.relaunch()
remote.app.exit()

View File

@ -151,6 +151,8 @@ function saveWindowConfig(browserWindow) {
return;
}
if(settings.get("NO_WINDOWS_BOUND"))return
settings.set('IS_MAXIMIZED', browserWindow.isMaximized());
settings.set('IS_MINIMIZED', browserWindow.isMinimized());
if (!settings.get('IS_MAXIMIZED') && !settings.get('IS_MINIMIZED')) {
@ -203,14 +205,14 @@ function doAABBsOverlap(a, b) {
}
function applyWindowBoundsToConfig(mainWindowOptions) {
if (!settings.get('WINDOW_BOUNDS')) {
const bounds = settings.get('WINDOW_BOUNDS')
if (!bounds) {
mainWindowOptions.center = true;
return;
}
const bounds = settings.get('WINDOW_BOUNDS');
bounds.width = Math.max(MIN_WIDTH, bounds.width);
bounds.height = Math.max(MIN_HEIGHT, bounds.height);
bounds.width = typeof bounds.width === "number" ? Math.max(MIN_WIDTH, bounds.width) : mainWindowOptions.width;
bounds.height = typeof bounds.height === "number" ? Math.max(MIN_HEIGHT, bounds.height) : mainWindowOptions.height;
let isVisibleOnAnyScreen = false;
const displays = electron.screen.getAllDisplays();