vscode icon indicating copy to clipboard operation
vscode copied to clipboard

set accessibility mode on reload of window

Open meganrogge opened this issue 2 years ago • 4 comments

fixes https://github.com/microsoft/vscode/issues/167583

Blocked by the chromium fix but works in OSS

meganrogge avatar Dec 06 '22 23:12 meganrogge

Blocked by the chromium fix but works in OSS

Is this referring to https://github.com/microsoft/vscode/pull/167960#issuecomment-1338639913 ? That would be only for macOS.

deepak1556 avatar Dec 07 '22 02:12 deepak1556

Oh ok great then this should be good to review and merge

meganrogge avatar Dec 07 '22 02:12 meganrogge

open is called in places where app refers to CodeApplication and thus does not have an isAccessibilitySupportEnabled function to call

I'm not familiar with this code - would you recommend I save the value of that before this https://github.com/microsoft/vscode/blob/71cd323fa9d0dffa881490f49b5c53ce9ba6fef2/src/vs/code/electron-main/app.ts#L870 happens and pass that in to all of the open calls?

meganrogge avatar Dec 07 '22 16:12 meganrogge

@meganrogge windowImpl is still in electron-main and has access to Electron app module, see for example:

https://github.com/microsoft/vscode/blob/b92894493e6f971a3c71912d823e699d3a05d643/src/vs/platform/windows/electron-main/windowImpl.ts#L485

Same goes for windowsMainService if we want to put this into the config.

Bottom line: instead of sending an IPC message to the window, I would send this information to the window as part of the config when opening.

bpasero avatar Dec 08 '22 04:12 bpasero

it turns out, we're already passing that in as an option, but not updating the accessibility service on reload

https://github.com/microsoft/vscode/blob/a3dd458dc0e92eccee2390bba81615386447a8d3/src/vs/platform/windows/electron-main/windowsMainService.ts#L1380

meganrogge avatar Dec 08 '22 23:12 meganrogge

@meganrogge there is a way to update the configuration explicitly when doing a window reload, see here:

https://github.com/microsoft/vscode/blob/422b581e3802e30cfb780c21d9cc1a2cd0c9f0aa/src/vs/platform/windows/electron-main/windowImpl.ts#L1043

For example we update some properties here:

https://github.com/microsoft/vscode/blob/422b581e3802e30cfb780c21d9cc1a2cd0c9f0aa/src/vs/platform/windows/electron-main/windowImpl.ts#L1069-L1070

I would think we can set accessibility mode too.

bpasero avatar Dec 09 '22 05:12 bpasero

@bpasero Thanks for the code pointers and continued discussion.

Based on logging, the values on environmentService.window do not get updated on reload and I don't think that's possible

It seems that consumers of INativeWorkbenchEnvironmentService end up using the storage service for this case instead

For example: https://github.com/microsoft/vscode/blob/60bbd421a19e0443852712a8c74ce056a225e59a/src/vs/workbench/services/themes/electron-sandbox/nativeHostColorSchemeService.ts#L28-L59

When I open a window, the property is known. When I changed the theme to light and reloaded, logging the value of the theme shows that it was not correct (thus the necessity of the storage service)

Screenshot 2022-12-09 at 11 02 58 AM

meganrogge avatar Dec 09 '22 17:12 meganrogge

@meganrogge theming might do something very special for other reasons, do not take it as an example. The values of the environment service will be updated based on the main side configuration from the reload call, can you try it?

bpasero avatar Dec 09 '22 17:12 bpasero

I tried that and the value was undefined - perhaps because of a timing issue?

meganrogge avatar Dec 09 '22 17:12 meganrogge

I noticed continueOn also uses the storage service and policiesData is used in initServices - which we can't do for the accessibilityService

meganrogge avatar Dec 09 '22 17:12 meganrogge

@meganrogge a simple example works for me, here are my changes:

In windowImpl.ts.reload():

configuration.verbose = true;

In constructor of window.ts:

console.log(this.environmentService.verbose);

On first start I get false and on reload true.

bpasero avatar Dec 09 '22 17:12 bpasero

It does appear to be working for me now

meganrogge avatar Dec 09 '22 17:12 meganrogge

Oh I had my old changes still, hopefully it will work when I remove them as well

Think I see what's wrong though

meganrogge avatar Dec 09 '22 17:12 meganrogge

@bpasero it was already on INativeWindowConfiguration

meganrogge avatar Dec 12 '22 18:12 meganrogge

that already happens here

https://github.com/microsoft/vscode/blob/84b9f9386aa15a6f4af12d570648dcdf767660d3/src/vs/workbench/services/accessibility/electron-sandbox/accessibilityService.ts#L44

meganrogge avatar Dec 12 '22 18:12 meganrogge

Thanks for the help @bpasero 👍🏼

meganrogge avatar Dec 12 '22 20:12 meganrogge