Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Handle fullscreen state without accessing remote.window
Browse files Browse the repository at this point in the history
First step of getting remote out of the codebase.
  • Loading branch information
black-puppydog committed Mar 6, 2021
1 parent fe4e56b commit 2d7dba9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const electron = require('electron')
const { Value } = require('mutant')

module.exports = function () {
const win = electron.remote.getCurrentWindow()
const isFullScreen = Value(win.isFullScreen())
win.on('enter-full-screen', () => {
const isFullScreen = Value(false)
// receive the OS window state from the main process
electron.ipcRenderer.on('enter-full-screen', () => {
isFullScreen.set(true)
})
win.on('leave-full-screen', () => {
electron.ipcRenderer.on('leave-full-screen', () => {
isFullScreen.set(false)
})
return isFullScreen
Expand Down
8 changes: 8 additions & 0 deletions lib/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ module.exports = function Window (config, path, opts) {
}
}, opts))

// have to forward the OS window state to the renderer because it cannot
// access directly
window.on('enter-full-screen', (event, alwaysOnTop) => {
window.webContents.send("enter-full-screen");
})
window.on('leave-full-screen', (event, alwaysOnTop) => {
window.webContents.send("leave-full-screen");
})
electron.ipcMain.on('ready-to-show', handleReadyToShow)

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

0 comments on commit 2d7dba9

Please sign in to comment.