diff --git a/src/constants.js b/src/constants.js index 7c61599a0ea7b..38501081ff6df 100644 --- a/src/constants.js +++ b/src/constants.js @@ -4,6 +4,7 @@ const IpcChannels = { DISABLE_PROXY: 'disable-proxy', GET_SYSTEM_LOCALE: 'get-system-locale', GET_NAVIGATION_HISTORY: 'get-navigation-history', + IS_WAYLAND_PLATFORM: 'is-wayland-platform', STOP_POWER_SAVE_BLOCKER: 'stop-power-save-blocker', START_POWER_SAVE_BLOCKER: 'start-power-save-blocker', CREATE_NEW_WINDOW: 'create-new-window', diff --git a/src/main/index.js b/src/main/index.js index 52b9de779fd17..a02effdb9a2cb 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -290,6 +290,7 @@ function runApp() { let trayOnMinimize = false let trayWindows = [] const trayMaximizedWindows = {} + const isTrayOnMinimizeSupported = process.platform !== 'darwin' && (process.platform !== 'linux' || app.commandLine.getSwitchValue('ozone-platform') !== 'wayland') const userDataPath = app.getPath('userData') @@ -346,7 +347,7 @@ function runApp() { if (!openDeepLinksInNewWindow) { // Just focus the main window (instead of starting a new instance) if (mainWindow.isMinimized()) { - if (process.platform !== 'darwin' && trayOnMinimize) { + if (isTrayOnMinimizeSupported && trayOnMinimize) { trayClick(mainWindow) } else { mainWindow.restore() @@ -524,7 +525,7 @@ function runApp() { backendPreference = doc.value break case 'hideToTrayOnMinimize': - if (process.platform !== 'darwin') { + if (isTrayOnMinimizeSupported) { trayOnMinimize = doc.value } break @@ -1032,7 +1033,7 @@ function runApp() { // endregion Ensure child windows use same options since electron 14 - if (process.platform !== 'darwin') { + if (isTrayOnMinimizeSupported) { function manageTray(window, removeWindow = false) { if (tray) { if (!removeWindow) { @@ -1144,7 +1145,7 @@ function runApp() { return } - if (process.platform !== 'darwin' && trayOnMinimize && trayWindows.length > 0) { + if (isTrayOnMinimizeSupported && trayOnMinimize && trayWindows.length > 0) { trayClick(newWindow) } else { newWindow.show() @@ -1346,6 +1347,12 @@ function runApp() { } }) + ipcMain.handle(IpcChannels.IS_WAYLAND_PLATFORM, (event) => { + if (isFreeTubeUrl(event.senderFrame.url)) { + return app.commandLine.getSwitchValue('ozone-platform') === 'wayland' + } + }) + /** * @param {import('electron').WebContents} webContents * @param {string | undefined} [currentPath] @@ -1656,7 +1663,7 @@ function runApp() { await setMenu() break case 'hideToTrayOnMinimize': - if (process.platform !== 'darwin') { + if (isTrayOnMinimizeSupported) { trayOnMinimize = data.value if (!trayOnMinimize) { showHiddenWindows() } } @@ -2114,7 +2121,7 @@ function runApp() { }) } - if (process.platform !== 'darwin') { + if (isTrayOnMinimizeSupported) { app.on('before-quit', () => { if (tray) { tray.destroy() } }) diff --git a/src/preload/interface.js b/src/preload/interface.js index d8eb910d6109c..15107ec862afe 100644 --- a/src/preload/interface.js +++ b/src/preload/interface.js @@ -30,6 +30,13 @@ export default { return ipcRenderer.invoke(IpcChannels.GET_SYSTEM_LOCALE) }, + /** + * @returns {Promise} + */ + isWaylandPlatform: () => { + return ipcRenderer.invoke(IpcChannels.IS_WAYLAND_PLATFORM) + }, + /** * @param {string} path * @param {Record | null | undefined} query diff --git a/src/renderer/components/GeneralSettings/GeneralSettings.vue b/src/renderer/components/GeneralSettings/GeneralSettings.vue index b6c83cdeaa0b2..1699e0e1db706 100644 --- a/src/renderer/components/GeneralSettings/GeneralSettings.vue +++ b/src/renderer/components/GeneralSettings/GeneralSettings.vue @@ -42,7 +42,7 @@ @change="updateOpenDeepLinksInNewWindow" />