experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

devtools focus fix

+11 -22
+11 -22
index.js
··· 506 506 507 507 // Setup devtools for the background window (always open in debug mode) 508 508 if (DEBUG) { 509 - win.webContents.openDevTools({ mode: 'detach' }); 510 - 511 - win.webContents.on('devtools-opened', () => { 512 - if (win.isVisible()) { 513 - win.webContents.focus(); 514 - } else { 515 - app.focus(); 516 - } 517 - }); 509 + win.webContents.openDevTools({ mode: 'detach', activate: false }); 518 510 } 519 511 520 512 // Add to window manager ··· 1424 1416 1425 1417 // Check if devTools should be opened 1426 1418 if (params.openDevTools === true) { 1419 + const isDetached = params.detachedDevTools === true; 1427 1420 // Determine if detached mode should be used 1428 - const devToolsOptions = { 1429 - mode: params.detachedDevTools === true ? 'detach' : 'right' 1421 + // activate: false prevents devtools from stealing focus (only works with detach/undocked) 1422 + const devToolsOptions = { 1423 + mode: isDetached ? 'detach' : 'right', 1424 + activate: false 1430 1425 }; 1431 - 1426 + 1432 1427 console.log(`Opening DevTools for window ${bw.id} with options:`, devToolsOptions); 1433 1428 bw.webContents.openDevTools(devToolsOptions); 1434 - 1435 - // when devtools completely open 1436 - bw.webContents.on('devtools-opened', () => { 1437 - // if window is visible, focus content window 1429 + 1430 + // when devtools completely open, ensure content window has focus 1431 + bw.webContents.once('devtools-opened', () => { 1438 1432 if (bw.isVisible()) { 1439 - bw.webContents.focus(); 1440 - } 1441 - // otherwise force devtools focus 1442 - // (for some reason doesn't focus when no visible window...) 1443 - else { 1444 - app.focus(); 1433 + bw.focus(); 1445 1434 } 1446 1435 }); 1447 1436 }