Comments (5)
Same here..
from electron-window-state.
The algorithm that checks if the window can be displayed within display bounds is in the validateState()
method:
electron-window-state/index.js
Lines 45 to 69 in 6bb0a3f
Here is an explanation of what this is doing:
- Retrieve the display that most closely intersects the saved bounds, and get its bounds
- if the retrieved bounds is not deeply equal to the saved bounds:
- if the retrieved screen size is smaller than the saved screen size:
- if the saved window position values are bigger than the retrieved screen size:
- set the window position values to 0
- if the saved window size is bigger than the retrieved screen size:
- set the window size to the retrieved screen size
- if the saved window position values are bigger than the retrieved screen size:
- if the retrieved screen size is smaller than the saved screen size:
This logic has drawbacks because it only takes into accounts positive values. Therefore it only works with this exact dual screen setup (with the window previously positioned in the second screen which is bigger than the primary one):
from electron-window-state.
Mac OSX is handling the window positioning differently than Windows. This difference can be simply tested by manually setting the main window position in a basic electron-quick-start example.
With these options:
mainWindow = new BrowserWindow({
'x': -100,
'y': 0,
'width': 800,
'height': 600,
});
the window in Windows will be 100px off the main screen and partly in the second screen, while on Mac OSX the window will be fully on the main screen. You can't position a window between two screens in OSX.
We can understand that Windows has an extended desktop while Mac OSX has separate ones.
Actually electron-boilerplate
checks if the window is within a display bounds. See electron-boilerplate:src/helpers/window.js.
Microsoft VSCode seems to have an interesting implementation too. See vscode:src/vs/code/electron-main/window.ts
from electron-window-state.
PR #45 proposes to fix this issue. Check it out 🤙
from electron-window-state.
With the merge of #45 this issue is hopefully fixed 👍
Thx @MathieuDebit
from electron-window-state.
Related Issues (20)
- Store other/custom window state details (e.g. URL)
- Support multiple windows HOT 8
- Looking for maintainers HOT 2
- Specific window size and position are not remembered HOT 2
- App off the screen if user selects a different display as their main and then launches the electron app HOT 3
- Include the type definition file (index.d.ts) into npm package. HOT 1
- Type definition export is incorrect
- Window state saved when second screen disconnected HOT 1
- Suggestion: saving the open/close state
- WindowState.manage(win) makes BrowserWindow.loadURL() reject promise in electron 5.0.0+ (using 5.0.1)) HOT 4
- BrowswerWindow flashes and then closes
- Resizable results in strange behavior
- Specifying path param won't work
- Window state not persisted anymore HOT 5
- If previously closed with any edge(s) overflows the screen border, window will relaunch at left top corner. HOT 1
- Manage function breaks the ready-to-show event in electron HOT 1
- # HOT 1
- Window size not preserved correctly when multiple displays use different screen scaling (devicePixelRatio) HOT 1
- Try to maintain this lib and checkout here: https://www.npmjs.com/package/stateful-electron-window
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-window-state.