-
-
Save mlaurencin/cbd3096126cab1f5c99108f1b623fa5f to your computer and use it in GitHub Desktop.
BrowserWindow.getContentSize() does not behave the same as expected #25295
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
<link rel="stylesheet" type="text/css" href="./styles.css"> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
<button id="click">Click to Get Window Size</button> | |
We are using Node.js <script>document.write(process.versions.node)</script>, | |
Chromium <script>document.write(process.versions.chrome)</script>, | |
and Electron <script>document.write(process.versions.electron)</script>. | |
<script> | |
// You can also require other files to run in this process | |
require('./renderer.js') | |
</script> | |
</body> | |
</html> |
This file contains 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
const {app, BrowserWindow, ipcMain} = require('electron') | |
function createWindow () { | |
const mainWindow = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
webPreferences: { | |
nodeIntegration: true, | |
enableRemoteModule: true, | |
} | |
}) | |
mainWindow.loadFile('index.html') | |
// Open the DevTools. | |
mainWindow.webContents.openDevTools() | |
} | |
app.on('ready', createWindow) | |
//IPC Method | |
///* | |
ipcMain.on('change-sub-height', (event, arg) => { | |
let window = BrowserWindow.getAllWindows()[0] | |
let subWinSize = window.getSize() | |
window.setSize(Math.floor(subWinSize[0]), subWinSize[1]) | |
console.log("In main: " + subWinSize) | |
}) | |
//*/ | |
app.on('window-all-closed', function () { | |
if (process.platform !== 'darwin') { | |
app.quit() | |
} | |
}) | |
app.on('activate', function () { | |
if (BrowserWindow.getAllWindows().length === 0) { | |
createWindow() | |
} | |
}) |
This file contains 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 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
//IPC Method | |
const { ipcRenderer } = require('electron') | |
function outputSize(){ | |
// Remote Method | |
/* | |
const win = require('electron').remote.BrowserWindow.getFocusedWindow() | |
if (win) { | |
const [ width, height ] = win.getSize() | |
console.log("In renderer: " + width, height) | |
} | |
*/ | |
// IPC Method | |
ipcRenderer.send('change-sub-height', 'sent') | |
} | |
document.querySelector("#click").addEventListener("mousedown", outputSize) |
This file contains 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
BrowserWindow.getContentSize() does not behave the same as expected #25295
electron/electron#25295