Ensure mainWindow stays responsive after opening debug logs in fullscreen on MacOS
This commit is contained in:
parent
d3a18a197b
commit
d4142e10b8
1 changed files with 18 additions and 9 deletions
27
app/main.ts
27
app/main.ts
|
@ -1375,13 +1375,28 @@ async function openArtCreator() {
|
||||||
let debugLogWindow: BrowserWindow | undefined;
|
let debugLogWindow: BrowserWindow | undefined;
|
||||||
async function showDebugLogWindow() {
|
async function showDebugLogWindow() {
|
||||||
if (debugLogWindow) {
|
if (debugLogWindow) {
|
||||||
debugLogWindow.show();
|
doShowDebugLogWindow();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function doShowDebugLogWindow() {
|
||||||
|
if (debugLogWindow) {
|
||||||
|
// Electron has [a macOS bug][0] that causes parent windows to become unresponsive
|
||||||
|
// if it's fullscreen and opens a fullscreen child window. Until that's fixed, we
|
||||||
|
// only set the parent on MacOS is if the mainWindow is not fullscreen
|
||||||
|
// [0]: https://github.com/electron/electron/issues/32374
|
||||||
|
if (OS.isMacOS() && mainWindow?.isFullScreen()) {
|
||||||
|
debugLogWindow.setParentWindow(null);
|
||||||
|
} else {
|
||||||
|
debugLogWindow.setParentWindow(mainWindow ?? null);
|
||||||
|
}
|
||||||
|
debugLogWindow.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const titleBarOverlay = await getTitleBarOverlay();
|
const titleBarOverlay = await getTitleBarOverlay();
|
||||||
|
|
||||||
const options = {
|
const options: Electron.BrowserWindowConstructorOptions = {
|
||||||
width: 700,
|
width: 700,
|
||||||
height: 500,
|
height: 500,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
|
@ -1398,14 +1413,8 @@ async function showDebugLogWindow() {
|
||||||
sandbox: true,
|
sandbox: true,
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
preload: join(__dirname, '../bundles/debuglog/preload.js'),
|
preload: join(__dirname, '../bundles/debuglog/preload.js'),
|
||||||
nativeWindowOpen: true,
|
|
||||||
},
|
},
|
||||||
parent: mainWindow,
|
parent: mainWindow,
|
||||||
// Electron has [a macOS bug][0] that causes parent windows to become unresponsive if
|
|
||||||
// it's fullscreen and opens a fullscreen child window. Until that's fixed, we
|
|
||||||
// prevent the child window from being fullscreenable, which sidesteps the problem.
|
|
||||||
// [0]: https://github.com/electron/electron/issues/32374
|
|
||||||
fullscreenable: !OS.isMacOS(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
debugLogWindow = new BrowserWindow(options);
|
debugLogWindow = new BrowserWindow(options);
|
||||||
|
@ -1418,7 +1427,7 @@ async function showDebugLogWindow() {
|
||||||
|
|
||||||
debugLogWindow.once('ready-to-show', () => {
|
debugLogWindow.once('ready-to-show', () => {
|
||||||
if (debugLogWindow) {
|
if (debugLogWindow) {
|
||||||
debugLogWindow.show();
|
doShowDebugLogWindow();
|
||||||
|
|
||||||
// Electron sometimes puts the window in a strange spot until it's shown.
|
// Electron sometimes puts the window in a strange spot until it's shown.
|
||||||
debugLogWindow.center();
|
debugLogWindow.center();
|
||||||
|
|
Loading…
Add table
Reference in a new issue