()
| 100 | ) |
| 101 | |
| 102 | const startExecutor = () => { |
| 103 | if (executorWindow && !executorWindow.isDestroyed()) { |
| 104 | console.debug("can't recreate, a window is already running") |
| 105 | return |
| 106 | } |
| 107 | executorWindow = null |
| 108 | terminalKeyboardCapture = false |
| 109 | const executorUrl = getMainUrl() |
| 110 | const mbExecutor = new BrowserWindow({ |
| 111 | title: "OpenADE", |
| 112 | resizable: true, |
| 113 | titleBarStyle: "hidden", |
| 114 | titleBarOverlay: getTitleBarOverlayOptions(), |
| 115 | ...(process.platform === "darwin" |
| 116 | ? { |
| 117 | trafficLightPosition: { |
| 118 | x: 18, |
| 119 | y: 15, |
| 120 | }, |
| 121 | } |
| 122 | : {}), |
| 123 | show: false, |
| 124 | backgroundColor: "#202124", |
| 125 | alwaysOnTop: false, |
| 126 | webPreferences: { |
| 127 | nodeIntegration: false, |
| 128 | contextIsolation: true, |
| 129 | preload: path.join(__dirname, "preload.js"), |
| 130 | textAreasAreResizable: false, |
| 131 | spellcheck: true, |
| 132 | devTools: true, |
| 133 | backgroundThrottling: false, |
| 134 | scrollBounce: true, |
| 135 | }, |
| 136 | ...loadLastWindowSize(), |
| 137 | }) |
| 138 | |
| 139 | // Block Cmd+W (macOS) and Ctrl+W (Windows/Linux) from closing the window |
| 140 | // Intercept Cmd+R / Ctrl+R to do a graceful reload instead of Electron's default |
| 141 | // which causes a transient did-fail-load and briefly shows the cantLoad page |
| 142 | mbExecutor.webContents.on("before-input-event", (event, input) => { |
| 143 | const shortcutAction = getWindowKeyboardShortcutAction(input, process.platform, terminalKeyboardCapture) |
| 144 | if (shortcutAction === "block-window-close") { |
| 145 | event.preventDefault() |
| 146 | } |
| 147 | if (shortcutAction === "reload") { |
| 148 | event.preventDefault() |
| 149 | loadSite() |
| 150 | } |
| 151 | if (shortcutAction === "focus-input") { |
| 152 | event.preventDefault() |
| 153 | mbExecutor.webContents.send("app:focus-input-shortcut") |
| 154 | } |
| 155 | }) |
| 156 | |
| 157 | manageWindowsAutoHide(mbExecutor) |
| 158 | |
| 159 | let isHandlingFailedLoad = false |
no test coverage detected