Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7f1bf1d

Browse files
committedApr 26, 2025
Merge branch 'development' into feature/hide-member-only-videos
* development: Ensure there is at most one power save blocker per open window (#7247) Change author name (#7216) Migrate ExternalPlayerSettings and SponsorBlockSettings to the composition API (#7267) Migrate the FtButton component to the composition API (#7266) Cleanup event listener pass-through inline handlers (#7268) Feature/add Windows/MacOS Taskbar dock/jumplist task 'New Window' (#7049) Translated using Weblate (Hebrew) Translated using Weblate (Norwegian Bokmål) Translated using Weblate (Greek)
2 parents 9baf28d + 00cd807 commit 7f1bf1d

File tree

46 files changed

+501
-422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+501
-422
lines changed
 

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"main": "./dist/main.js",
88
"private": true,
99
"author": {
10-
"name": "PrestonN",
10+
"name": "FreeTube Team",
1111
"email": "FreeTubeApp@protonmail.com",
1212
"url": "https://github.com/FreeTubeApp/FreeTube"
1313
},

‎src/main/index.js

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ function runApp() {
225225
}
226226
})
227227

228+
if (process.platform === 'win32') {
229+
app.setUserTasks([
230+
{
231+
program: process.execPath,
232+
arguments: '--new-window',
233+
iconPath: process.execPath,
234+
iconIndex: 0,
235+
title: 'New Window',
236+
description: 'Open New Window'
237+
}
238+
])
239+
}
240+
228241
// disable electron warning
229242
process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'
230243
const isDebug = process.argv.includes('--debug')
@@ -292,6 +305,21 @@ function runApp() {
292305
let proxyUrl
293306

294307
app.on('ready', async (_, __) => {
308+
if (process.platform === 'darwin') {
309+
const dockMenu = Menu.buildFromTemplate([
310+
{
311+
label: 'New Window',
312+
click: () => {
313+
createWindow({
314+
replaceMainWindow: false,
315+
showWindowNow: true
316+
})
317+
}
318+
}
319+
])
320+
app.dock.setMenu(dockMenu)
321+
}
322+
295323
if (process.env.NODE_ENV === 'production') {
296324
protocol.handle('app', async (request) => {
297325
if (request.method !== 'GET') {
@@ -857,6 +885,8 @@ function runApp() {
857885
// Which raises "Object has been destroyed" error
858886
mainWindow = allWindows[0]
859887
}
888+
889+
stopPowerSaveBlockerForWindow(newWindow)
860890
})
861891
}
862892

@@ -1117,12 +1147,46 @@ function runApp() {
11171147
}
11181148
})
11191149

1120-
ipcMain.on(IpcChannels.STOP_POWER_SAVE_BLOCKER, (_, id) => {
1121-
powerSaveBlocker.stop(id)
1150+
/** @type {Map<number, number>} */
1151+
const activePowerSaveBlockers = new Map()
1152+
1153+
/**
1154+
* @param {BrowserWindow} window
1155+
*/
1156+
function stopPowerSaveBlockerForWindow(window) {
1157+
const powerSaveBlockerId = activePowerSaveBlockers.get(window.id)
1158+
1159+
if (typeof powerSaveBlockerId === 'number') {
1160+
powerSaveBlocker.stop(powerSaveBlockerId)
1161+
1162+
activePowerSaveBlockers.delete(window.id)
1163+
}
1164+
}
1165+
1166+
ipcMain.on(IpcChannels.STOP_POWER_SAVE_BLOCKER, (event) => {
1167+
if (!isFreeTubeUrl(event.senderFrame.url)) {
1168+
return
1169+
}
1170+
1171+
const browserWindow = BrowserWindow.fromWebContents(event.sender)
1172+
1173+
if (browserWindow) {
1174+
stopPowerSaveBlockerForWindow(browserWindow)
1175+
}
11221176
})
11231177

1124-
ipcMain.handle(IpcChannels.START_POWER_SAVE_BLOCKER, (_) => {
1125-
return powerSaveBlocker.start('prevent-display-sleep')
1178+
ipcMain.on(IpcChannels.START_POWER_SAVE_BLOCKER, (event) => {
1179+
if (!isFreeTubeUrl(event.senderFrame.url)) {
1180+
return
1181+
}
1182+
1183+
const browserWindow = BrowserWindow.fromWebContents(event.sender)
1184+
1185+
if (browserWindow && !activePowerSaveBlockers.has(browserWindow.id)) {
1186+
const powerSaveBlockerId = powerSaveBlocker.start('prevent-display-sleep')
1187+
1188+
activePowerSaveBlockers.set(browserWindow.id, powerSaveBlockerId)
1189+
}
11261190
})
11271191

11281192
ipcMain.on(IpcChannels.CREATE_NEW_WINDOW, (event, path, query, searchQueryText) => {

0 commit comments

Comments
 (0)
Please sign in to comment.