Skip to content

Window size changes when being moved if resizable is false #13043

Closed as not planned

Description

@wenjunche
  • Electron Version: 2.0.0
  • Operating System (Platform and Version): Windows 10
  • Last known working Electron version: before commit bb5eecc

Expected Behavior
Width and height of a window should not change while being dragged

Actual behavior
Width and height become smaller.

To Reproduce
Create a window with:
var mainWindow = new BrowserWindow({width: 1024, height: 880, x: 30, y: 30,
resizable: false })

Then drag the window. Width and height become smaller than specified (1024, 880)

Additional Information
NativeWindowViews::SetBounds calls SetMin/MaxSize(bounds) when resizable_ is false. bounds get adjusted to smaller numbers by WindowBoundsToContentBounds.

Activity

  1. welcome commented on May 22, 2018

    @welcome

    👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

    To help make it easier for us to investigate your issue, please follow the contributing guidelines.

  2. self-assigned this
    on May 22, 2018
  3. brenca commented on May 22, 2018

    @brenca
    Contributor

    So, just to confirm that we see the same thing - the windows stays visibly the same size, but a bunch of resize events get emitted with sizes that fluctuate between the size that was set and one that's one pixel off (and only when scaling is not 100%)?

  4. wenjunche commented on May 22, 2018

    @wenjunche
    Author

    scaling is at 100%. The window changes size as soon as I drag it.

    When I run the example I listed earlier, the followings are what I see in devtools->console

    Before I move the window:

    window.outerHeight
    880
    window.outerWidth
    1024

    After I move the window

    window.outerHeight
    851
    window.outerWidth
    1018

  5. brenca commented on May 22, 2018

    @brenca
    Contributor

    Can you make me a repo to reproduce this? I've found something that I thought was what you were talking about, but now I'm not sure I know what's going on.

    I tested this with 2.0.2, do you see this with that version?

  6. added a commit that references this issue on May 22, 2018
  7. wenjunche commented on May 22, 2018

    @wenjunche
    Author
  8. brenca commented on May 24, 2018

    @brenca
    Contributor

    Are you using the non-detached devtools? If so, I think I know what you mean.

  9. incomingstick commented on Jun 20, 2018

    @incomingstick

    I would like to add that I am seeing the same issue. We use not attached dev tools as well, however this is also reproducible on an electron-forge binary build of our app as well (which obviously does not open the dev tools), so I do not know if that is a cause.

    My app starts at a size of 846x478 and upon dragging only the first time after the app has opened it becomes 840x449. Which happens to be the exact loss of 6x29 as seen above. Our repo is unfortunately private, so I cannot share the link. Please let me know what information you may need from me.

    We are using electron version 2.0.2 and I am on Windows 10 version 1709 (OS Build 16299.371)

  10. jahraphael commented on Jun 20, 2018

    @jahraphael

    I wanted to follow up to what @incomingstick with a couple more things:

  11. ianshade commented on Jul 25, 2018

    @ianshade

    I'm facing the same issue but I noticed that it happens only when the menu is present. When I disable the menu with window.setMenu(null); the window moves fine.

  12. 24 remaining items

  13. th3jesta commented on Jul 7, 2021

    @th3jesta

    Experiencing in 13.1.4. Very irritating.

  14. hgalocy commented on Jul 30, 2021

    @hgalocy

    This line fixes the bug:

    win.on('will-move', (e) => { win.setSize(yourWidth, yourHeight) });

    Adjust your width and height accordingly.

  15. github-actions commented on Oct 8, 2022

    @github-actions
    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!

  16. github-actions commented on Nov 8, 2022

    @github-actions
    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.

  17. edosssa commented on Jan 6, 2023

    @edosssa

    Still happening :(

  18. parkdongcheol commented on Aug 29, 2023

    @parkdongcheol

    I found a solution for this issue by setting win.setPosition( x, y ). I set my coordinates to where I wanted the window to load and found that there is no longer any unwanted resizing.

    I am unsure if this is a blanket solution, but it did fix this re-sizing issue while setResizeable is set to false.

    Currently using release 25.5.0

    Good luck!

  19. fzf404 commented on Sep 18, 2023

    @fzf404

    It's still happening in Electron 26.2.1.

  20. ButzYung commented on Sep 23, 2023

    @ButzYung

    I found a solution for this issue by setting win.setPosition( x, y ). I set my coordinates to where I wanted the window to load and found that there is no longer any unwanted resizing.

    I am unsure if this is a blanket solution, but it did fix this re-sizing issue while setResizeable is set to false.

    Currently using release 25.5.0

    Good luck!

    This seems to work when device pixel ratio is 1. However, the problem is back if it isn't 1 (when you set "Make everything bigger" to anything above 100% under Windows).

  21. parkdongcheol commented on Sep 27, 2023

    @parkdongcheol

    I found a solution for this issue by setting win.setPosition( x, y ). I set my coordinates to where I wanted the window to load and found that there is no longer any unwanted resizing.
    I am unsure if this is a blanket solution, but it did fix this re-sizing issue while setResizeable is set to false.
    Currently using release 25.5.0
    Good luck!

    This seems to work when device pixel ratio is 1. However, the problem is back if it isn't 1 (when you set "Make everything bigger" to anything above 100% under Windows).

    Good to know this tidbit now. Thanks for the feedback!

  22. LucileGrnd commented on Mar 13, 2024

    @LucileGrnd

    Hi, any news about this?

  23. MSJavaScript commented on Apr 9, 2024

    @MSJavaScript

    Hi, any news about this?
    I may case, the window size changes if I write

    win.setMenu(null);
    win.loadFile('index.html');

    However, if I move the setMenu line below, the problem is solved

    win.loadFile('index.html');
    win.setMenu(null);
  24. DenisFV commented on May 31, 2024

    @DenisFV

    Calling setSize() twice fixes this

  25. farid-azihub commented on Jan 13, 2025

    @farid-azihub

    I found a solution for this issue by setting win.setPosition( x, y ). I set my coordinates to where I wanted the window to load and found that there is no longer any unwanted resizing.

    I am unsure if this is a blanket solution, but it did fix this re-sizing issue while setResizeable is set to false.

    Currently using release 25.5.0

    Good luck!

    This fixed the issue for me, thanks!
    @parkdongcheol

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions