Set initial window size depending on screen size (#5845)
* set initial electron window size to be almost full screen with some space left * refine initial window size and position * slightly larger * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 * A snapshot a day keeps the bugs away! 📷🐛 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 143 KiB |
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
17
src/main.ts
@ -10,6 +10,7 @@ import {
|
|||||||
nativeTheme,
|
nativeTheme,
|
||||||
desktopCapturer,
|
desktopCapturer,
|
||||||
systemPreferences,
|
systemPreferences,
|
||||||
|
screen,
|
||||||
} from 'electron'
|
} from 'electron'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { Issuer } from 'openid-client'
|
import { Issuer } from 'openid-client'
|
||||||
@ -86,12 +87,24 @@ const createWindow = (pathToOpen?: string, reuse?: boolean): BrowserWindow => {
|
|||||||
newWindow = mainWindow
|
newWindow = mainWindow
|
||||||
}
|
}
|
||||||
if (!newWindow) {
|
if (!newWindow) {
|
||||||
|
const primaryDisplay = screen.getPrimaryDisplay()
|
||||||
|
const { width, height } = primaryDisplay.workAreaSize
|
||||||
|
|
||||||
|
const windowWidth = Math.max(500, width - 150)
|
||||||
|
const windowHeight = Math.max(400, height - 100)
|
||||||
|
|
||||||
|
const x = primaryDisplay.workArea.x + Math.floor((width - windowWidth) / 2)
|
||||||
|
const y =
|
||||||
|
primaryDisplay.workArea.y + Math.floor((height - windowHeight) / 2)
|
||||||
|
|
||||||
newWindow = new BrowserWindow({
|
newWindow = new BrowserWindow({
|
||||||
autoHideMenuBar: false,
|
autoHideMenuBar: false,
|
||||||
show: false,
|
show: false,
|
||||||
enableLargerThanScreen: true,
|
enableLargerThanScreen: true,
|
||||||
width: 1800,
|
width: windowWidth,
|
||||||
height: 1200,
|
height: windowHeight,
|
||||||
|
x,
|
||||||
|
y,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: false, // do not give the application implicit system access
|
nodeIntegration: false, // do not give the application implicit system access
|
||||||
contextIsolation: true, // expose system functions in preload
|
contextIsolation: true, // expose system functions in preload
|
||||||
|