Skip to content

Windows 10 Browser Window Bounds Calculating Incorrectly #4045

Closed

Description

@kirkouimet

The Browser Window width and x coordinates are being calculated incorrectly in Windows 10 (Windows 8.1 did not have this problem). Here you can see that the getBounds() function is showing that my x value is 0 but the desktop background is showing through. I'm guessing this may have something to do with a subtle shadow that each window in Windows 10 is now casting.

image

Not sure how to fix this, but would be nice to resolve as I have some window state management code written to pin windows in the correct location, and now they are not properly being positioned.

Activity

  1. kirkouimet commented on Jan 10, 2016

    @kirkouimet
    ContributorAuthor

    Here is one more screenshot. In this screenshot the window should be positioned in the bottom left of the screen - you can see there is padding on the left, bottom, and right. Interestingly, the y value seems to be working correctly, so if you set y to zero it will appropriately put the window right at the top of the screen.

    image

  2. kirkouimet commented on Jan 10, 2016

    @kirkouimet
    ContributorAuthor

    And lastly, here is my code (specific to my window state management class) which addresses the issue until an official fix comes out:

    // Temporary hack to fix Windows 10 browser window sizing issues until Electron is fixed
    if(Node.OperatingSystem.platform() == 'win32' && Node.OperatingSystem.release().startsWith('10.')) {
        this.x = this.x - 7;
        this.width = this.width + 14;
        this.height = this.height + 7;
    }
    
  3. zcbenz commented on Jan 11, 2016

    @zcbenz
    Contributor

    Windows 10 has a thinner frame than before, and in order to be compatible with existing apps it is returning wrong values in its win32 APIs. You can reproduce the same problem in Chrome browser:

    screen shot 2016-01-11 at 3 25 55 pm

    I have reported the problem to upstream: https://crbug.com/576192.

  4. lukeapage commented on Jul 5, 2016

    @lukeapage
    Contributor

    @zcbenz @kirkouimet I see the linked bug in chrome is closed as cannot reproduce - is this bug fixed or do you still have the problem?

  5. intsrc commented on Jul 6, 2016

    @intsrc

    the problem is still here!

  6. kirkouimet commented on Jul 6, 2016

    @kirkouimet
    ContributorAuthor

    Yeah someone is going to have to go and reopen that Chromium ticket and follow it through to the end

  7. anaisbetts commented on Feb 14, 2017

    @anaisbetts
    Contributor

    Would setting a new key in our App manifest opt us out of this?

  8. zcbenz commented on Feb 14, 2017

    @zcbenz
    Contributor

    I hope so, but I can't find any documentation on it, even this behavior is not documented anywhere.

  9. anaisbetts commented on Feb 14, 2017

    @anaisbetts
    Contributor

    Alright, I sent an Email to the relevant Microsoft MVP mailing list, we'll see if anyone has any ideas

  10. bsclifton commented on Apr 26, 2017

    @bsclifton
    Contributor

    Was this fixed with #9167 ?

  11. kevinsawicki commented on Apr 26, 2017

    @kevinsawicki
    Contributor

    Was this fixed with #9167 ?

    Perhaps, @kirkouimet could you confirm this as fixed in 1.6.7+?

  12. kirkouimet commented on Oct 31, 2017

    @kirkouimet
    ContributorAuthor

    @kevinsawicki and @bsclifton this is still an issue as of Electron 1.8.2 on Windows 10 updated October 2017

  13. 15 remaining items

  14. appurist commented on Dec 13, 2019

    @appurist

    This is still a problem in Electron 6.1.5. It's going to be a major problem for my app.

    I can fix (only) the left position by using a negative number, but it seems the width and height always fall short even if I set them larger.

  15. pushkin- commented on Mar 5, 2020

    @pushkin-

    Can repro with Electron 8

  16. Stanzilla commented on Mar 7, 2020

    @Stanzilla

    @zcbenz @MarshallOfSound this is affecting high profile apps like Discord, any chance someone could look into it?

  17. Ansraer commented on Jun 4, 2020

    @Ansraer

    Managed to reproduce this issue with both vs code and Discord on a 1920x1080 display. Based on my testing the window is exactly 10px to wide/tall. I am currently running Windows 10 18362.
    I would be happy to help with testing and/or collecting more data if someone can tell me what information is required.

  18. gerbus commented on Jun 19, 2020

    @gerbus

    Still happening with Electron 8.2.2.

    It's possible based on my investigation that BrowserWindow.getBounds() in Windows 10 should be returning the equivalent of window.innerHeight and window.innerWidth but isn't.

    windows_dimensions_mismatch

    At the top of my devtools console, you can see the output of BrowserWindow.getBounds(), followed by dimensions from the browser's window object.

    In my case, I'm setting the dimensions on a BrowserView to fit its parent BrowserWindow. When I set the dimensions on my BrowserView as follows, things seem to fit perfectly on Windows 10, and in Windows 7 (both basic and classic themes):

    browserView.setBounds({
        width: browserWindow.getBounds().width - (window.outerWidth - window.innerWidth),
        height: browserWindow.getBounds().height - (window.outerHeight - window.innerHeight),
    });
    
  19. nbanerje commented on Aug 14, 2020

    @nbanerje

    Is there an update on when this might be addressed or what the best workaround is?

  20. lynxtaa commented on Aug 18, 2020

    @lynxtaa
    Contributor

    In my case I'm opening new child window alongside the right border of the parent window to fill the empty screen space. Right now my code looks like this. Looks hacky but works okay (Electron v9.1.0). Hope it helps:

    const currentWindow = remote.getCurrentWindow()
    let { x, y, height, width } = currentWindow.getBounds()
    const { workAreaSize } = remote.screen.getPrimaryDisplay()
    
    // https://github.com/electron/electron/issues/4045#issuecomment-170399607
    if (isWindows10()) {
      width -= 14
    }
    
    // https://github.com/electron/electron/issues/501
    if (currentWindow.isMaximized()) {
      y += 7
    }
    
    const childWindowMinWidth = 500
    const childWindowWidth = Math.max(workAreaSize.width - width - x, childWindowMinWidth)
    
    const childWindow = new remote.BrowserWindow({
      height,
      minWidth: childWindowMinWidth,
      width: childWindowWidth,
      x: Math.min(width + x, workAreaSize.width - childWindowWidth),
      y,
      parent: currentWindow,
      minimizable: false,
    })
  21. electron-triage commented on Mar 9, 2021

    @electron-triage

    The Electron version reported on this issue is no longer supported. See our supported versions documentation.

    If this is still reproducible on a supported version, please open a new issue with any other new information that a maintainer should know.

    Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated.

  22. Stanzilla commented on Mar 9, 2021

    @Stanzilla

    Well that's an annoying bot. Could at least ask if it is still an issue and then update the label.

  23. appurist commented on Mar 9, 2021

    @appurist

    "Thank you for taking the time to report this issue and helping to make Electron better! Your help is appreciated."

    Ignore the bug report for 4 years -- TEN major releases -- and then close it due to it being reported against an unsupported version. "Brilliant" way to manage issue lists getting long.

    I disabled my apps' features of remembering window size and position, as a temporary workaround to this problem. (Not really a workaround.) For a while I tested this problem on every major update, and was one of the people who confirmed it was still present, for a while, delaying that feature while I hoped an update might include a fix. I stopped retesting it after many major releases did not include any fix, or any sign of interest by Electron folks. Apparently, for those updates where I did retest it, I was wasting my time.

    This is very discouraging, if not infuriating. And unfortunately this kind of policy will only damage code quality, especially as developers such as myself, see this as a clear reason to halt efforts to try to narrow down Electron bugs, to take the time to reproduce the problems and file bug reports against Electron, and instead begin the process of finding and migrating to different solutions to cross-platform development needs.

  24. junguksim commented on Sep 29, 2022

    @junguksim

    Is this issue fixed? Still repro in 11.2.1

  25. ricardomomm commented on Apr 4, 2024

    @ricardomomm

    Still happening on Windows 11

  26. ThaUnknown commented on Jan 4, 2025

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions