Skip to content

BrowserWindow's "will-resize" event's callback is provided with bizarre newBounds value #19611

Closed

Description

@alitaheri

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:
    • 6.0.0
  • Operating System:
    • MacOS any
  • Last Known Working Electron version:
    • none that I know of

Expected Behavior

The actual new bounds (correct x, y, width and height) to be provided as the new bounds to the callback of will-resize event

Actual Behavior

On mac (and only mac) it provides some very bizarre values. It seems that the y and x are actually calculated from the BOTTOM-RIGHT corner of the DISPLAY bounds to the BOTTOM-RIGHT of the window bounds. Instead of the usual (by that I mean what you get from getBounds) x and y that is calculated from the TOP-LEFT of the DISPLAY to the TOP-LEFT of the window.

in other words imagine this:

My display is 100x100 and I have a window at 10, 20 with width: 30, and height 40

the getBounds function gives me (10, 20, 30, 40) all good.

when I resize from the TOP, UP for 1 pixel, the new bounds would be: (10, 19, 10, 41)

because the height is increased by one, while the y is reduced by one.

however the will-resize event on MAC gives me: (60, 40, 10, 41)

60 is the display.width - bounds.width - bounds.x.
40 is the display.height - bounds.height - bounds.y. why?!

and what's worse? there is no way to transform these, because not only the x and the y are wrong, they never reflect what is going on, that means, even if I resize from BOTTOM in the UP direction, it still gives me the same WRONG newBounds.

this means, there is absolutely no way to even work around this issue. I have no way of knowing whether the user dragged the TOP edge down or the BOTTOM edge down. the data is so bizarre that I spent a whole day trying to figure out what the values meant and how I could fix them. there is no way. It has to be fixed here

To Reproduce

Simply listen to will-resize of any window and log the newBounds argument.

Activity

  1. pouyakary commented on Aug 3, 2019

    @pouyakary

    @deermichel — I guess another thing you can checkout

  2. deermichel commented on Aug 5, 2019

    @deermichel
    Contributor

    Yeah i guess the same strange things happen with Tray - let's see what i can do...

  3. self-assigned this
    on Aug 5, 2019
  4. alitaheri commented on Aug 6, 2019

    @alitaheri
    Author

    @deermichel Thank you for taking care of this on such short notice 👍

  5. pouyakary commented on Aug 9, 2019

    @pouyakary

    thanks a lot @deermichel 😍

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

Metadata

Metadata

Assignees

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