Skip to content

Commit

Permalink
fix a bug where the webxdc was able to open the dev tools.
Browse files Browse the repository at this point in the history
Also make opening devtools with F12 more reliable.
  • Loading branch information
Simon-Laux committed Sep 7, 2023
1 parent 8e3ecd3 commit d3ffbff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
### Changed

### Fixed
- webxdc: fix a bug where the webxdc was able to open the dev tools.
Also make opening devtools with F12 more reliable.

<a id="1_40_2"></a>

Expand Down
15 changes: 9 additions & 6 deletions src/main/deltachat/webxdc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,17 @@ If you think that's a bug and you need that permission, then please open an issu
callback(permission_handler(permission))
}
)
}
)

ipcMain.handle('webxdc.toggle_dev_tools', async event => {
if (DesktopSettings.state.enableWebxdcDevTools) {
event.sender.toggleDevTools()
webxdc_windows.webContents.on('before-input-event', (event, input) => {
if (input.key.toLowerCase() === 'f12') {
if (DesktopSettings.state.enableWebxdcDevTools) {
webxdc_windows.webContents.toggleDevTools()
event.preventDefault()
}
}
})
}
})
)

ipcMain.handle('webxdc.exitFullscreen', async event => {
const key = Object.keys(open_apps).find(
Expand Down
7 changes: 1 addition & 6 deletions static/webxdc-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,7 @@
})

const keydown_handler = ev => {
if (ev.key == 'F12') {
ipcRenderer.invoke('webxdc.toggle_dev_tools')
ev.preventDefault()
ev.stopImmediatePropagation()
ev.stopPropagation()
} else if (ev.key == 'Escape') {
if (ev.key == 'Escape') {
ipcRenderer.invoke('webxdc.exitFullscreen')
}
}
Expand Down

0 comments on commit d3ffbff

Please sign in to comment.