Set focus and blur on macOS

This commit is contained in:
Korbs 2024-03-27 18:02:35 -04:00
parent 5e427e3477
commit add278e443
No known key found for this signature in database

View file

@ -46,12 +46,16 @@ module.exports = {
ipcMain.on('UnmaximizeWindow', () => {mainWindow.restore()})
ipcMain.on('MinimizeWindow', () => {mainWindow.minimize()})
// Move Tabs when entering or existing fullscreen on macOS
if (process.platform === 'darwin') {
// Move Tabs when entering or existing fullscreen on macOS
mainWindow.on('enter-full-screen', (e, cmd) => {mainWindow.webContents.executeJavaScript(`document.querySelector("tab-group").shadowRoot.querySelector("nav").style.left = '0px'`)})
mainWindow.on('leave-full-screen', (e, cmd) => {mainWindow.webContents.executeJavaScript(`document.querySelector("tab-group").shadowRoot.querySelector("nav").style.left = '80px'`)})
// Fade Top Bar if the end-user leaves the window on macOS
mainWindow.on('blur', (e, cmd) => {mainWindow.webContents.executeJavaScript(`document.querySelector("body > sl-include:nth-child(4) > tab-group").shadowRoot.querySelector("div > nav").style.opacity = '0.5'`)})
mainWindow.on('focus', (e, cmd) => {mainWindow.webContents.executeJavaScript(`document.querySelector("body > sl-include:nth-child(4) > tab-group").shadowRoot.querySelector("div > nav").style.opacity = '1'`)})
}
// Other Functions
mainWindowState.manage(mainWindow)
Menu.MainMenu()