Created
September 13, 2021 23:25
-
-
Save jjeff/078e07a2e6efd589365717e81094bbd6 to your computer and use it in GitHub Desktop.
Electron Multi-Screen Window Placement Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Empty --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Modules to control application life and create native browser window | |
const {app, BrowserWindow} = require('electron') | |
const path = require('path') | |
function createWindow () { | |
// Create the browser window. | |
const mainWindow = new BrowserWindow({ | |
width: 840, | |
height: 900, | |
webPreferences: { | |
preload: path.join(__dirname, 'preload.js'), | |
experimentalFeatures: true | |
} | |
}) | |
// and load the index.html of the app. | |
// mainWindow.loadFile('index.html') | |
mainWindow.loadURL('https://michaelwasserman.github.io/window-placement-demo/') | |
} | |
// This method will be called when Electron has finished | |
// initialization and is ready to create browser windows. | |
// Some APIs can only be used after this event occurs. | |
app.whenReady().then(() => { | |
createWindow() | |
app.on('activate', function () { | |
// On macOS it's common to re-create a window in the app when the | |
// dock icon is clicked and there are no other windows open. | |
if (BrowserWindow.getAllWindows().length === 0) createWindow() | |
}) | |
}) | |
// Quit when all windows are closed, except on macOS. There, it's common | |
// for applications and their menu bar to stay active until the user quits | |
// explicitly with Cmd + Q. | |
app.on('window-all-closed', function () { | |
if (process.platform !== 'darwin') app.quit() | |
}) | |
// In this file you can include the rest of your app's specific main process | |
// code. You can also put them in separate files and require them here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "hurried-son-back-k3x3w", | |
"productName": "hurried-son-back-k3x3w", | |
"description": "My Electron application description", | |
"keywords": [], | |
"main": "./main.js", | |
"version": "1.0.0", | |
"author": "jeff", | |
"scripts": { | |
"start": "electron ." | |
}, | |
"dependencies": {}, | |
"devDependencies": { | |
"electron": "15.0.0-beta.4" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener('DOMContentLoaded', () => { | |
const v = process.versions | |
console.log('Electron: %s\nChrome: %s\nNode: %s\nV8: %s', v.electron, v.chrome, v.node, v.v8) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Empty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Empty */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is an Electron Fiddle project to see if Electron works with Chrome's upcoming Multi-screen Window Placement API. It just opens a window to https://michaelwasserman.github.io/window-placement-demo/.
Note that until Chrome 97 is released and becomes a part of Electron, this API is only available with
webPreference.experimentalFeatures = true
when creating a BrowserWindow.Tested through Electron 15 beta 4.
Current bug: Screens are recognized and drawn correctly on the demo page. However, there appears to be a bug where
requestFullscreen()
always opens on the primary screen.