RocketChat / Rocket.Chat.Electron

Official OSX, Windows, and Linux Desktop Clients for Rocket.Chat
https://rocket.chat/
MIT License
1.59k stars 704 forks source link

Reopened window size is multiplied with scale factore #2379

Open MCMicS opened 2 years ago

MCMicS commented 2 years ago

My Setup

Description

  1. Open the app and put on monitor with scale factor (like 4K monitor).
  2. Quit the app and restart again.

Current Behavior

The Window size is scaled with the factor.

Expected Behavior

The window has same size as before quit the application.

This is because following change with 17.2.0: https://github.com/electron/electron/blob/17-x-y/patches/chromium/set_dpi_correctly_during_main_window_creation.patch#L36

One workaround is to set the setSize after initialization of the BrowserWindow like:

browserWindow.setSize(width, height)
jeanfbrito commented 2 years ago

Hey @MCMicS I didnt understood the issue. The window is saving the scaled size and when you reopen it the window gets bigger? I don't have a high DPI monitor to test with Windows. Please provide some screenshots or a little video/gif.

MCMicS commented 2 years ago

Yes it will increase. if you close the app and reopen it the size will be bigger.

a high dpi should not needed. It should also happen if set you scale in WIndows (https://www.windowscentral.com/how-set-custom-display-scaling-setting-windows-10)

I try to provide an gif later the day

see attached video: https://user-images.githubusercontent.com/4604206/161988891-cf239449-a73c-4d9b-a029-b8cd20ae7060.mp4

jeanfbrito commented 2 years ago

@MCMicS could you test it with the latest version? For me it doesn't happens anymore. I think that was an Electron bug. I will close it, if it happens yet, tell me and we can open again.

MCMicS commented 2 years ago

With version 3.8.12 it still occurs.

And yes it is an electron issue or rather an issue of the time when the window bound are restored.

jeanfbrito commented 2 years ago

I cant reproduce it on my Windows 10. Did you have this problem on another machine? I couldn't see how this could happen just on one machine. Its very weird.

MCMicS commented 2 years ago

I have tested on another machine with different environment. The problem still occurs but in some strange behaviour. It is needed to use two monitors. Environment 1:

Environment :

*Conclusion It seem that the primary display will be used to restore the last stored window bounds. Then the window will moved to the last position on second screen and afterwards the size will adapted to the dpi of the current display.

I also created an internal application based on Electron who had this issue. My solution the days before the electron fix was provided was to call setSize after initialization of the BrowserWindow. But I have not check now if it the issue was completely solved (now I'm using Electron 20.x). B