Not planned
Description
I want to change the zoom level of child windows from main process, but it does not have any affect. Neither passing zoomFactor to BrowserWindow nor calling setZoomFactor on web contents work. Here is an example code where I try to change zoom factor on child window https://github.com/zarubond/electron-quick-start/tree/child_zoom
Preflight Checklist
- I have read the Contributing Guidelines for this project.I agree to follow the Code of Conduct that this project adheres to.I have searched the issue tracker for an issue that matches the one I want to file, without success.
Issue Details
- Electron Version:
5.0.10, 6.0.2 - Operating System:
MacOS, Linux, Windows - Last Known Working Electron version:
Never?
Expected Behavior
I should be able to change zoom factor of any window from main process
Actual Behavior
Any attempt to change it is ignored
To Reproduce
Try to change zoom factor of any child window
Activity
loc commentedon Sep 5, 2019
The handler bound to
ready-to-show
is not running, so the webContents.setZoomFactor is never getting called. The handler isn't running because your window is immediately shown, so the event isn't emitted.Relevant bit of docs, for reference:
So, if you add a
show: false
to your BrowserWindow options and anevent.newGuest.show()
afterready-to-show
, it should work as you expect.One reason that it's not setting the zoomFactor when you initialize the BrowserWindow is that
zoomFactor
is a property ofwebPreferences
, not of the top-level options type.That being said, with zoomFactor correctly situated, you're still right, it doesn't work at BrowserWindow instantiation. It looks like this is because the native-window-opened webContents is already created by the time you intercept the
new-window
event, and Electron's zoom controller isn't updated when the webPreferences are merged at BrowserWindow creation.11 remaining items