Skip to content

BrowserWindow min-width and min-height not set consistently with width and height properties #1806

Closed

Description

@jilltowle

I'm seeing two problems with the min-width and min-height properties.

First, when opening a window that includes the native window chrome, the window width and height that is set when creating the window includes the width and height of the native window chrome. So if I set width to 800px and height to 600px, the entire window is 800 x 600. However, if we also set min-width to 800px and min-height to 600px, these measurements seem to exclude the native chrome. So if I try to resize it at all (or even to drag the window on Windows), it will resize itself so that the contents (excluding the chrome) are 800 x 600. The window will get bigger by the size of the chrome, which is the height of the header on OSX and about 15px x 38px on Windows.

Secondly, on Windows only, if you have auto-scaling turned on, this is being applied once when opening the BrowserWindow with a specified width and height, but is being applied a second time when evaluating min-width and min height. For example, my PC has a screen resolution of 3200 x 1800, and the recommended scaling is 200%. With these settings, if we create a browser window as 400px wide and 300px high, then it's actually created as 800 x 600, which is what I'd expect with 200% scaling. However, it seems that if I also set the min-width to 400 and the min-height to 300, and drag or attempt to resize the window, then the minimum dimensions are evaluated, and doubled again, so I end up with a window that jumps to twice the expected size (1626 x 1271). While I can get around this by turning off auto-scaling (setting scaling to 100%), because the recommended setting for my resolution is to have this turned on, I would expect that a lot of Windows users with high-resolution monitors would run into a similar problem.

Thank you.

Activity

  1. ToadKing commented on Sep 1, 2015

    @ToadKing

    The second issue with scaling on Windows is still an issue in 0.31.1.

    EDIT: Possibly related to that issue; on scaled desktops, window.outerHeight / outerWidth are set incorrectly. They appear to be scaled down based on the windows desktop scale ratio. So if you have desktop scaling set to 200%, a window 800px wide will have a outerWidth of 400.

  2. ToadKing commented on Sep 8, 2015

    @ToadKing

    It only appears to happen if you change the DPI settings on the main monitor. Changing it for secondary monitors does not break min-width/height.

  3. smebberson commented on Sep 16, 2015

    @smebberson

    Users of my application are experiencing this too. I'm setting height and width, and min-height and min-width all to the same value. When they try to resize, or drag, it doubles in size (Windows).

  4. ToadKing commented on Sep 22, 2015

    @ToadKing

    Right now I've been working around this with this hack. On systems with minimal to no window chrome it works well enough for my application.

    var minWidth = 500;
    var minHeight = 400;
    var ratio = 1;
    if (window.outerWidth < window.innerWidth) {
      ratio = window.outerWidth / window.innerWidth;
    }
    require('remote').getCurrentWindow().setMinimumSize(Math.round(ratio * minWidth), Math.round(ratio * minHeight));

    I've tried clamping it to nearest 0.25 values to get around the extra pixels the window chrome adds but depending on your monitor the exact value of this ratio may not be a perfectly round decimal.

  5. added a commit that references this issue on Oct 3, 2015
    aea1f8a
  6. ToadKing commented on Oct 7, 2015

    @ToadKing

    There is still an issue with high-dpi desktops on Windows even in 0.33.6 with #2979 applied.

  7. etiktin commented on Oct 7, 2015

    @etiktin
    Contributor

    v0.33.6 doesn't include the fix. If you go the releases page and click "X commits to master since this release", you'll see it's still waiting.

  8. ToadKing commented on Oct 7, 2015

    @ToadKing

    Oops, my bad. I thought that meant commits since last release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions