Skip to content
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

Window size and position is incorrect when the app is launched. #868

Closed
doraemoon-bot opened this issue Oct 27, 2022 · 9 comments · Fixed by #1402
Closed

Window size and position is incorrect when the app is launched. #868

doraemoon-bot opened this issue Oct 27, 2022 · 9 comments · Fixed by #1402
Labels
bug Something isn't working fix-available A fix to the issue is available in a new version

Comments

@doraemoon-bot
Copy link

doraemoon-bot commented Oct 27, 2022

I use a Windows laptop with multiple displays.
When I restart the app, it changes size and position.
I don't know Electron, but I think it stems from the way the display object is retrieved.

youtube-music/index.js

Lines 159 to 160 in 1f5f597

const displaySize =
electron.screen.getDisplayNearestPoint(windowPosition).bounds;

My display scale settings may also have an effect.
Here is a screenshot of the details.
(Please note that my locale in the screenshots is Japanese.)

My display settings

  • [1] is the laptop and [3] is the main display.
    This problem only occurs when the app is placed on a laptop display and not on any other displays.

ss1

Scale and layout

  • laptop display
    ss2
  • other displays
    ss3

Size and position before restart

  • The app is on the laptop display.
    ss4

Size and position after restart

  • Sized and positioned from the main display?
    ss5

config.json

  • before restart
    ss6
  • after restart
    ss7
@Sickjuicy
Copy link
Contributor

Sickjuicy commented Nov 1, 2022

I have the same Issue.

My temp fix is to set the windows-size in the config.

First put it at 1000x1000 or something else. After that restart the app. Than you need to resize it with the config and dont touch the window.

Sorry for my bad english :)

@Araxeus
Copy link
Collaborator

Araxeus commented Feb 10, 2023

Could this be because you have a 125% zoom on the laptop?

does this still happen if you set your zoom to 100%?

@Sickjuicy
Copy link
Contributor

Sickjuicy commented Feb 10, 2023

I have the same issue as the person with the laptop but I have it on my desktop PC I have no problems on my first monitor with a 100% zoom but on my second monitor with 150% zoom I have the same problem

EDIT: Same for the position, on the second monitor.

@Araxeus
Copy link
Collaborator

Araxeus commented Feb 10, 2023

150% zoom I have the same problem

Can you try changing the zoom to 100% and see if it fixes the issue?

If it does, then this issue might be that #548 doesn't take in account zoom level.

Will have to see if there are some calculations to be made using Electron.Display.scaleFactor

https://www.electronjs.org/docs/latest/api/structures/display
https://www.electronjs.org/docs/latest/api/screen

I'm currently unsure what the updated calculation would be, any help would be appreciated

@Sickjuicy
Copy link
Contributor

Sickjuicy commented Feb 10, 2023

I put the second screen on 100% and it got fixed.

EDIT: I put it pack and the size and position changed again

@Sickjuicy
Copy link
Contributor

I dont know if it helps but I think I found a Stack Overflow thread about it.
https://stackoverflow.com/questions/57900207/how-to-avoid-windows-zoom-in-electron-app

@Araxeus
Copy link
Collaborator

Araxeus commented Feb 10, 2023

stackoverflow.com/questions/57900207/how-to-avoid-windows-zoom-in-electron-app

I don't think this really help because we don't want to disable zooming inside the app right?

I think this issue happen because this part doesn't take into account zoom factor somehow:

youtube-music/index.js

Lines 162 to 167 in 7bdbab5

if (
x + winSize[0] < displaySize.x - 8 ||
x - winSize[0] > displaySize.x + displaySize.width ||
y < displaySize.y - 8 ||
y > displaySize.y + displaySize.height
) {

I'm not sure which of those value is affected by the zoom/scale factor. have to do some manual testing.

Sickjuicy referenced this issue May 24, 2023
Added windows ScaleFactor
@JellyBrick
Copy link
Collaborator

Fixed at #1159

@JellyBrick JellyBrick added the bug Something isn't working label Oct 7, 2023
@JellyBrick JellyBrick reopened this Oct 8, 2023
@JellyBrick JellyBrick added the help wanted Extra attention is needed label Oct 8, 2023
@JellyBrick
Copy link
Collaborator

Workaround to fix this issue (#1159) caused issue #1273, so I'll revert it and reopen this issue.

@JellyBrick JellyBrick added fix-available A fix to the issue is available in a new version and removed help wanted Extra attention is needed labels Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix-available A fix to the issue is available in a new version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants