Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 2d7dba9

Browse files
Handle fullscreen state without accessing remote.window
First step of getting remote out of the codebase.
1 parent fe4e56b commit 2d7dba9

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/fullscreen.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const electron = require('electron')
22
const { Value } = require('mutant')
33

44
module.exports = function () {
5-
const win = electron.remote.getCurrentWindow()
6-
const isFullScreen = Value(win.isFullScreen())
7-
win.on('enter-full-screen', () => {
5+
const isFullScreen = Value(false)
6+
// receive the OS window state from the main process
7+
electron.ipcRenderer.on('enter-full-screen', () => {
88
isFullScreen.set(true)
99
})
10-
win.on('leave-full-screen', () => {
10+
electron.ipcRenderer.on('leave-full-screen', () => {
1111
isFullScreen.set(false)
1212
})
1313
return isFullScreen

lib/window.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ module.exports = function Window (config, path, opts) {
1111
}
1212
}, opts))
1313

14+
// have to forward the OS window state to the renderer because it cannot
15+
// access directly
16+
window.on('enter-full-screen', (event, alwaysOnTop) => {
17+
window.webContents.send("enter-full-screen");
18+
})
19+
window.on('leave-full-screen', (event, alwaysOnTop) => {
20+
window.webContents.send("leave-full-screen");
21+
})
1422
electron.ipcMain.on('ready-to-show', handleReadyToShow)
1523

1624
window.webContents.on('dom-ready', function () {

0 commit comments

Comments
 (0)