Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change zoom level on child windows #20084

Closed
3 tasks done
zarubond opened this issue Sep 3, 2019 · 3 comments
Closed
3 tasks done

Unable to change zoom level on child windows #20084

zarubond opened this issue Sep 3, 2019 · 3 comments

Comments

@zarubond
Copy link
Contributor

zarubond commented Sep 3, 2019

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

@loc
Copy link
Contributor

loc commented 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:

While loading the page, the ready-to-show event will be emitted when the renderer process has rendered the page for the first time if the window has not been shown yet.

So, if you add a show: false to your BrowserWindow options and an event.newGuest.show() after ready-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 of webPreferences, 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.

@sofianguy sofianguy added this to Unsorted Issues in 6.1.x Sep 18, 2019
@sofianguy sofianguy added this to Unsorted Issues in 5.0.x Sep 18, 2019
@sofianguy sofianguy added 6-1-x and removed 6-0-x labels Feb 19, 2020
@ckerr ckerr added this to TODO in Issues Jun 9, 2020
@ckerr ckerr moved this from TODO to Backlog in Issues Jun 16, 2020
@codebytere codebytere moved this from Backlog / Unsorted to Prioritized in Issues Jun 24, 2020
@codebytere codebytere removed this from Prioritized in Issues Jun 24, 2020
@nornagon nornagon added blocked/need-repro Needs a test case to reproduce the bug and removed blocked/need-repro Needs a test case to reproduce the bug labels Sep 15, 2022
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the latest version of Electron or in the beta—please include it with your comment!

@github-actions github-actions bot added the stale label Jan 10, 2023
@github-actions
Copy link
Contributor

This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a supported version of Electron please open a new issue and include instructions for reproducing the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
5.0.x
Unsorted Issues
6.1.x
Unsorted Issues
Development

No branches or pull requests

5 participants