mawie81 / electron-window-state

A library to store and restore window sizes and positions for your Electron app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

if (state.x > displayBounds.width) { correct?

greggman opened this issue · comments

if (state.x > displayBounds.width) {

Just curious how state.x can be compared to displayBounds.width. state.x is not related to displayBounds.width. Maybe you meant to compare it to right as in displayBounds.x + displayBounds.width?

Or maybe I'm just not understanding the logic.

It looks like that is there to ensure the state's X coordinate is not out of the screen bounds. This ensures that the window does not appear off screen.

@M1kep is correct 😃

If the user has more than one display is this check still valid?

It looks like screen is defined by the electron screen. I'm not positive right now, but I believe that is the current screen the app is on. And display bounds is based on that screen object.

not sure what you mean. The display bounds are defined by x, y, width and height. Checking my two monitors via electron I see one has a bound.x of -1440

note if you don't have 2 monitors but you have an Apple TV (or Android TV running an AirPlay app) you can use that as a second monitor

If I'm not being clear, Imaging you have 2 monitors. One is right of the other. The bounds for the 2 monitors are

x: 0, y: 0, width: 1000, height: 500
x: 1000, y: 0, width: 1000, height: 500

If displayBounds = screen.getDisplayMatching(state).bounds; returns the second monitor then state.x will >= 1000 so the test state.x > displayBounds.width will fail even though you want it to pass. It seems like the correct test is state.x > displayBounds.x + displayBounds.width?