Skip to content

Replace applicationStorageMainService with stateMainService#169365

Merged
Tyriar merged 1 commit intomicrosoft:mainfrom
Kalmaegi:poricess_explore
Dec 27, 2022
Merged

Replace applicationStorageMainService with stateMainService#169365
Tyriar merged 1 commit intomicrosoft:mainfrom
Kalmaegi:poricess_explore

Conversation

@Kalmaegi
Copy link
Contributor

@Kalmaegi Kalmaegi commented Dec 16, 2022

resolved #169363

@Kalmaegi
Copy link
Contributor Author

Kalmaegi commented Dec 16, 2022

@Tyriar I found a small problem, here if we use the screen scale as a divisor, it will cause the length and width to be reduced when it is created, on Mac, the scale is 2, probably because we did not consider the screen scale when storing or we don't need to think about it on Mac?

https://github.com/microsoft/vscode/blob/461b3f6184b1668be469901bf0fc75a426e0bb81/src/vs/platform/issue/electron-main/issueMainService.ts#LL284

@bpasero
Copy link
Member

bpasero commented Dec 16, 2022

Cool!

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@weartist oh so do we need to also store the scale and only update it when it changes? Going from one monitor to the other for me worked fine so I think something fishy is going on 🤔

@Kalmaegi
Copy link
Contributor Author

@weartist oh so do we need to also store the scale and only update it when it changes? Going from one monitor to the other for me worked fine so I think something fishy is going on 🤔

It may be related to the operating system, I will look at the related logic, if you do not use scale, will the size of the window on your Windows be enlarged?

@Tyriar
Copy link
Member

Tyriar commented Dec 16, 2022

Yes, saving the state on my second monitor would make the window 50% larger when I reopen the explorer.

@Kalmaegi
Copy link
Contributor Author

Yes, saving the state on my second monitor would make the window 50% larger when I reopen the explorer.

That probably does need to be scaled, my monitors have the same resolution, I'll check the logic here

@bpasero
Copy link
Member

bpasero commented Dec 16, 2022

I am not sure if it would be worthwhile maybe making this code reusable:

private validateWindowState(state: IWindowState, displays: Display[]): IWindowState | undefined {

We use it to validate the window state is in bounds of the display. In general I would argue that window state storing and restoring is relatively complex, so there is probably lots of good knowledge already for workbench windows to look at.

Here is how we serialize the state:

serializeWindowState(): IWindowState {

@Kalmaegi
Copy link
Contributor Author

I am not sure if it would be worthwhile maybe making this code reusable:

private validateWindowState(state: IWindowState, displays: Display[]): IWindowState | undefined {

We use it to validate the window state is in bounds of the display. In general I would argue that window state storing and restoring is relatively complex, so there is probably lots of good knowledge already for workbench windows to look at.

Here is how we serialize the state:

serializeWindowState(): IWindowState {

Thank! I'll go and understand the logic here

@Kalmaegi
Copy link
Contributor Author

Kalmaegi commented Dec 17, 2022

@Tyriar Does your monitor have amplified DPI? e.g 200% DPI
strangely, the size we obtained was already scaleFactor, My monitor resolution is 3840 x 2160, I was at the time of getting its size 1920 x 1080 and scaleFactor is 2, when I drag the new window to full screen, The resulting dimensions are almost 1920 x 1080, It doesn't look like you need to consider scaleFactor.
So I was wondering if there were other factors affecting the scaling of the created window, Probably not a location-related issue. Or do your two monitors have different resolutions?

@Tyriar
Copy link
Member

Tyriar commented Dec 27, 2022

@weartist it's a 4k monitor at 1.5 scale in the OS, next to a 1080p monitor at 1 scale

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow up! For the scale issue, I tested it again and it does still happen. it's relatively minor as I think it would only happen when you have mixed scale monitors.

@Tyriar Tyriar added this to the January 2023 milestone Dec 27, 2022
@Tyriar Tyriar merged commit 19171f9 into microsoft:main Dec 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Feb 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use state service for process explorer state

4 participants