Skip to content

Commit 95e3df0

Browse files
screen capture fix
1 parent 1996c7c commit 95e3df0

2 files changed

Lines changed: 37 additions & 36 deletions

File tree

full.js

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,26 @@ const attach = (event, webContents) => {
8888
}
8989
})
9090

91+
webContents.session.setPermissionCheckHandler((webContents, permission) => {
92+
console.log(`[PERMISSION DEBUG] Permission check for: "${permission}"`)
93+
return permission === 'media' || permission === 'display-capture' || permission === 'desktopCapture'
94+
})
95+
96+
webContents.session.setDisplayMediaRequestHandler((request, callback) => {
97+
console.log('[DISPLAY MEDIA DEBUG] Display media request received')
98+
desktopCapturer.getSources({ types: ['screen', 'window'] }).then((sources) => {
99+
console.log('[DISPLAY MEDIA DEBUG] Available sources:', sources.length)
100+
if (sources.length > 0) {
101+
callback({ video: sources[0], audio: 'loopback' })
102+
} else {
103+
callback({})
104+
}
105+
}).catch(err => {
106+
console.error('[DISPLAY MEDIA DEBUG] Error getting sources:', err)
107+
callback({})
108+
})
109+
})
110+
91111
webContents.on('will-navigate', (event, url) => {
92112
if (!webContents.opened) {
93113
// The first time this view is being used, set the "opened" to true, and don't do anything
@@ -555,6 +575,7 @@ if (!gotTheLock) {
555575
app.commandLine.appendSwitch('enable-features', 'GetDisplayMediaSet,GetDisplayMediaSetAutoSelectAllScreens');
556576

557577
app.whenReady().then(async () => {
578+
app.userAgentFallback = "Pinokio"
558579

559580
// PROMPT
560581
let promptResponse
@@ -636,9 +657,20 @@ document.querySelector("form").addEventListener("submit", (e) => {
636657
},
637658
browser: {
638659
clearCache: async () => {
639-
console.log('clear cache', session.defaultSession)
660+
console.log('clear cache from all sessions')
661+
662+
// Clear default session
640663
await session.defaultSession.clearStorageData()
641-
console.log("cleared")
664+
665+
// Clear all custom sessions from active windows
666+
const windows = BrowserWindow.getAllWindows()
667+
for (const window of windows) {
668+
if (window.webContents && window.webContents.session) {
669+
await window.webContents.session.clearStorageData()
670+
}
671+
}
672+
673+
console.log("cleared all sessions")
642674
}
643675
}
644676
})
@@ -647,39 +679,8 @@ document.querySelector("form").addEventListener("submit", (e) => {
647679
theme = pinokiod.theme
648680
colors = pinokiod.colors
649681

650-
// Set global permission handler for screen capture
651-
session.defaultSession.setPermissionRequestHandler((webContents, permission, callback) => {
652-
console.log(`[PERMISSION DEBUG] Global session permission requested: "${permission}"`)
653-
if (permission === 'media' || permission === 'display-capture' || permission === 'desktopCapture') {
654-
console.log(`[PERMISSION DEBUG] Global session granting permission: "${permission}"`)
655-
callback(true)
656-
} else {
657-
console.log(`[PERMISSION DEBUG] Global session denying permission: "${permission}"`)
658-
callback(false)
659-
}
660-
})
661682

662-
// Enable desktop capture
663-
session.defaultSession.setPermissionCheckHandler((webContents, permission) => {
664-
console.log(`[PERMISSION DEBUG] Permission check for: "${permission}"`)
665-
return permission === 'media' || permission === 'display-capture' || permission === 'desktopCapture'
666-
})
667683

668-
// Handle getDisplayMedia requests to make web API work
669-
session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
670-
console.log('[DISPLAY MEDIA DEBUG] Display media request received')
671-
desktopCapturer.getSources({ types: ['screen', 'window'] }).then((sources) => {
672-
console.log('[DISPLAY MEDIA DEBUG] Available sources:', sources.length)
673-
if (sources.length > 0) {
674-
callback({ video: sources[0], audio: 'loopback' })
675-
} else {
676-
callback({})
677-
}
678-
}).catch(err => {
679-
console.error('[DISPLAY MEDIA DEBUG] Error getting sources:', err)
680-
callback({})
681-
})
682-
})
683684

684685
app.on('web-contents-created', attach)
685686
app.on('activate', function () {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "Pinokio",
33
"private": true,
4-
"version": "3.52.0",
4+
"version": "3.79.0",
55
"homepage": "https://pinokio.co",
66
"description": "pinokio",
77
"main": "main.js",
88
"email": "cocktailpeanuts@proton.me",
99
"author": "https://twitter.com/cocktailpeanut",
1010
"scripts": {
11-
"start": "electron .",
11+
"start": "./node_modules/.bin/electron .",
1212
"pack": "./node_modules/.bin/electron-builder --dir",
1313
"eject": "hdiutil info | grep '/dev/disk' | awk '{print $1}' | xargs -I {} hdiutil detach {}",
1414
"l": "docker run --rm -ti -v $PWD:/project -w /project -e SNAPCRAFT_BUILD_ENVIRONMENT=host -e SNAP_DESTRUCTIVE_MODE=true electronuserland/builder bash -lc 'rm -rf node_modules && npm install && npm run monkeypatch && ./node_modules/.bin/electron-builder install-app-deps && ./node_modules/.bin/electron-builder -l'",
@@ -119,7 +119,7 @@
119119
"electron-store": "^8.1.0",
120120
"electron-updater": "^6.6.2",
121121
"electron-window-state": "^5.0.3",
122-
"pinokiod": "^3.52.0"
122+
"pinokiod": "^3.79.0"
123123
},
124124
"devDependencies": {
125125
"@electron/rebuild": "3.2.10",

0 commit comments

Comments
 (0)