WebPrefrences.ZoomFactor is int instead of double #867

Closed
opened 2026-01-29 16:50:46 +00:00 by claunia · 4 comments
Owner

Originally created by @Yuvix25 on GitHub (Apr 2, 2023).

  • Electron.NET Version: 23.6.1
  • .NET Version: 7.0.202
  • Node.js Version: 18.12.1
  • Target: Windows

I want to make my app resolution fixed to 1920x1080 no matter what's the screen resolution, while still keeping the app full screen. To achieve that, I tried the following:

double factor = (await Electron.Screen.GetPrimaryDisplayAsync()).WorkAreaSize.Width / 1920.0;
var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions()
{
    WebPreferences = new WebPreferences()
    {
        ZoomFactor = factor,
    },
    Resizable = false,
    Fullscreen = true,
    Minimizable = false,
    Movable = false,
    Frame = false,
    Transparent = true,
    BackgroundColor = "#00000000",
});

However, this did not work, as ZoomFactor is expecting an int, not a double, unlike the original implementation in Electron.JS where it is indeed a double.

Can this be fixed?
(From a quick look at the source code, it seems as the only change necessary is public int ZoomFactor { get; set; } to public double ZoomFactor { get; set; }, but I'm not entirely sure, so I prefer not posting this as a PR)

Originally created by @Yuvix25 on GitHub (Apr 2, 2023). <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Electron.NET Version**: 23.6.1 * **.NET Version**: 7.0.202 * **Node.js Version**: 18.12.1 * **Target**: Windows <!-- Enter your issue details below this comment. --> I want to make my app resolution fixed to 1920x1080 no matter what's the screen resolution, while still keeping the app full screen. To achieve that, I tried the following: ```cs double factor = (await Electron.Screen.GetPrimaryDisplayAsync()).WorkAreaSize.Width / 1920.0; var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions() { WebPreferences = new WebPreferences() { ZoomFactor = factor, }, Resizable = false, Fullscreen = true, Minimizable = false, Movable = false, Frame = false, Transparent = true, BackgroundColor = "#00000000", }); ``` However, this did not work, as `ZoomFactor` is expecting an int, not a double, unlike the [original implementation in Electron.JS](https://www.electronjs.org/docs/latest/api/web-frame#webframesetzoomfactorfactor) where it is indeed a double. Can this be fixed? (From a quick look at the source code, it seems as the only change necessary is `public int ZoomFactor { get; set; }` to `public double ZoomFactor { get; set; }`, but I'm not entirely sure, so I prefer not posting this as a PR) <!-- If you want, you can donate to increase issue priority (https://donorbox.org/electron-net) -->
claunia added the bug label 2026-01-29 16:50:46 +00:00
Author
Owner

@FlorianRappl commented on GitHub (Apr 2, 2023):

Yes, I think this can be fixed and that the fix would be indeed as simple as the suggestion. Do you want to make a PR on this? Thanks!

@FlorianRappl commented on GitHub (Apr 2, 2023): Yes, I think this can be fixed and that the fix would be indeed as simple as the suggestion. Do you want to make a PR on this? Thanks!
Author
Owner

@Yuvix25 commented on GitHub (Apr 2, 2023):

Sure, I'll make one!

@Yuvix25 commented on GitHub (Apr 2, 2023): Sure, I'll make one!
Author
Owner

@FlorianRappl commented on GitHub (Apr 3, 2023):

Thanks! Merged and will be part of the next release. 🍻

@FlorianRappl commented on GitHub (Apr 3, 2023): Thanks! Merged and will be part of the next release. :beers:
Author
Owner

@GregorBiswanger commented on GitHub (Apr 3, 2023):

Will be taken into account in the next update release.

Thank you @Yuvix25 for your PR.

@GregorBiswanger commented on GitHub (Apr 3, 2023): Will be taken into account in the **next update release**. Thank you @Yuvix25 for your PR.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#867