-
-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop: fix window dimensions and position when the application start #2514
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could try to corrupt the window-state-prod.json
on purpose. On macOS, this file is in ~/Library/Application Support/Joplin
. Not sure about Linux and Windows.
This is a great start, but to bring it to the next level, I'd suggest the following: make the default size and position dependent of the screen size. e.g. that it takes 80%-85% of the width and height and that it is centered. This is just an idea and not necessary. |
set minWidth/minHeight also solves the user occasionally scale the window to a minimum @daukadolt I suggest to set the |
@tessus I've made default width and height dependent on the primary screen, since that is the screen that the app is spawned on for the first time. However, Travis build has failed and I wonder why. After a quick run through the logs and repo it seems that the first line intended for eslint is the culprit, but how come did the master repo build successfully? Or my commit somehow messes with it. And why is the build performed on laurent22/master instead of my master branch? Additionally, I tried playing around with |
Right now all builds fail in Travis. We have to fix that. So don't worry about it right now. I'll have a look at your new commit either tonight or tomorrow. |
@gasolin I like your suggestion, I will commit updated minimum dimensions after all other issues will be resolved |
Please rebase, so that the conflicts are resolved. This will also solve the Travis builds. The build process has changed, so everything should be fine now. Please have a look at the updated BUILD.md file. |
Hardcoded minimum width and height of 100 px. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com>
Set Electron window at the center of primaryDisplay if BrowserWindow is not on any displays. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com>
Set Electron window defaultWidth, defaultHeight to 80% of primary display workArea width, height, respectively. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com>
Got it. I've checked the updated test steps. What do you think about @gasolin 's suggestion on minWidth/minHeight? I can change them if everything else is fine. |
Hotfix of a typo that calculates Electron app's default height at first run using primary screen's width, not height. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com>
Found a typo in my code, sorry for the sloppiness. However, here again, BrowserWindow safeguards against too big of a height. Doing |
@PackElend could you please tag this PR as gsoc-2020 as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'd change the defaultWidth
and defaultHeight
to something more sane.
Or depending on the actual screen size.
@tessus you mean using screen size instead of workArea? |
I meant that if your screen is e.g. 1024x768, use ca 80-85% of that for the window size. Maybe 800x600 and position it (1024-800)/2 , (800-600)/2 so that it is in the middle of the screen. This should of course only be done, if there's a problem with the size or the position in the first place. If the data in |
ElectronClient/ElectronAppWrapper.js
Outdated
@@ -43,9 +43,12 @@ class ElectronAppWrapper { | |||
|
|||
const windowStateKeeper = require('electron-window-state'); | |||
|
|||
const currentWorkArea = screen.getPrimaryDisplay().workArea; | |||
const [defaultWidth, defaultHeight] = [0.8*currentWorkArea.width, 0.8*currentWorkArea.height]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please round the values. Also I don't see a need to create these separate values, so if you could set the properties on stateOptions directly that would be best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@laurent22 can you take a look at the changes?
Just left one comments. @tessus, is there something more that needs to be changed? I see he already uses 80% of the space or did I miss something? |
No, @laurent22, all is good. The OP has already changed the code according to my suggestion. |
Perfect, then there's just this one minor change to make and we can merge. |
Setting defaultWidth/defaultHeight directly without extra variables. Rounding defaultWidth/defaultHeight. Signed-off-by: daukadolt <daulet.amirkhanov.official@gmail.com>
Bump. This is still happening with Joplin 2.6.10 (prod, win32) Client ID: cf27eb0272a5451ca45a96eaa6351910 Revision: 98fba37 This issue appeared only on my multi-monitor setup - after I deleted the folder in |
@scotrod and all, this is still happening on Multi monitor and laptop's main display, docked and undocked. OS: Windows 11 22H2 (OS Build 22621.1555) |
Addresses #2476
Electron app doesn't allow scaling any lower than minHeight and minWidth, which I've checked. However, I could not enforce the application to have a position outside my only display both through setting x, y manually here or through BrowserWindow.setPosition(). Hence, I could not check my solution on this one.
I initially wanted to discuss my approach (like setting arbitrary 100px for minHeight/minWidth) in the issue, but (sorry if I'm wrong) I thought that since pull request would either way be reviewed discussion could be set here.
Looking forward for comments.