*
()
| 32 | * |
| 33 | */ |
| 34 | function createWindow () { |
| 35 | |
| 36 | /* |
| 37 | * see https://www.electronjs.org/docs/latest/api/screen |
| 38 | * Create a window that fills the screen's available work area. |
| 39 | */ |
| 40 | let electronSize = { width: 800, height: 600 }; |
| 41 | try { |
| 42 | electronSize = electron.screen.getPrimaryDisplay().workAreaSize; |
| 43 | } catch { |
| 44 | Log.warn("Could not get display size, using defaults ..."); |
| 45 | } |
| 46 | |
| 47 | applyElectronSwitches(app.commandLine, config.electronSwitches); |
| 48 | let electronOptionsDefaults = { |
| 49 | width: electronSize.width, |
| 50 | height: electronSize.height, |
| 51 | icon: "favicon.svg", |
| 52 | x: 0, |
| 53 | y: 0, |
| 54 | darkTheme: true, |
| 55 | webPreferences: { |
| 56 | contextIsolation: true, |
| 57 | nodeIntegration: false, |
| 58 | zoomFactor: config.zoom |
| 59 | }, |
| 60 | backgroundColor: "#000000" |
| 61 | }; |
| 62 | |
| 63 | electronOptionsDefaults.show = false; |
| 64 | electronOptionsDefaults.frame = false; |
| 65 | electronOptionsDefaults.transparent = true; |
| 66 | electronOptionsDefaults.hasShadow = false; |
| 67 | electronOptionsDefaults.fullscreen = true; |
| 68 | |
| 69 | const electronOptions = Object.assign({}, electronOptionsDefaults, config.electronOptions); |
| 70 | |
| 71 | if (process.env.MOCK_DATE !== undefined) { |
| 72 | // if we are running tests and we want to mock the current date |
| 73 | const fakeNow = new Date(process.env.MOCK_DATE).valueOf(); |
| 74 | Date = class extends Date { |
| 75 | constructor (...args) { |
| 76 | if (args.length === 0) { |
| 77 | super(fakeNow); |
| 78 | } else { |
| 79 | super(...args); |
| 80 | } |
| 81 | } |
| 82 | }; |
| 83 | const __DateNowOffset = fakeNow - Date.now(); |
| 84 | const __DateNow = Date.now; |
| 85 | Date.now = () => __DateNow() + __DateNowOffset; |
| 86 | } |
| 87 | |
| 88 | // Create the browser window. |
| 89 | mainWindow = new BrowserWindow(electronOptions); |
| 90 | |
| 91 | /* |
no test coverage detected