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

update accessibility mode on window reload #168246

Merged
merged 18 commits into from
Dec 12, 2022
Merged

Conversation

meganrogge
Copy link
Contributor

@meganrogge meganrogge commented Dec 6, 2022

fixes #167583

@meganrogge meganrogge self-assigned this Dec 6, 2022
@meganrogge meganrogge marked this pull request as draft December 6, 2022 23:14
@meganrogge meganrogge requested a review from deepak1556 December 6, 2022 23:14
@meganrogge meganrogge added this to the December 2022 milestone Dec 6, 2022
@deepak1556
Copy link
Collaborator

Blocked by the chromium fix but works in OSS

Is this referring to #167960 (comment) ? That would be only for macOS.

@meganrogge
Copy link
Contributor Author

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

@meganrogge meganrogge marked this pull request as ready for review December 7, 2022 02:57
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

Why does this have to be a IPC message sent from app.ts and why can this not be one of the configuration options that we pass into a window here:

const configuration: INativeWindowConfiguration = {

@meganrogge
Copy link
Contributor Author

meganrogge commented Dec 7, 2022

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

const app = this;

happens and pass that in to all of the open calls?

@bpasero
Copy link
Member

bpasero commented Dec 8, 2022

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

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.

@meganrogge meganrogge dismissed a stale review via a3dd458 December 8, 2022 23:15
@meganrogge
Copy link
Contributor Author

meganrogge commented Dec 8, 2022

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

accessibilitySupport: app.accessibilitySupportEnabled,

@meganrogge meganrogge changed the title set accessibility mode on reload of window update accessibility mode on window reload Dec 8, 2022
@meganrogge meganrogge requested a review from bpasero December 8, 2022 23:28
@bpasero
Copy link
Member

bpasero commented Dec 9, 2022

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

async reload(cli?: NativeParsedArgs): Promise<void> {

For example we update some properties here:

configuration.policiesData = this.policyService.serialize(); // set policies data again
configuration.continueOn = this.environmentMainService.continueOn;

I would think we can set accessibility mode too.

@meganrogge
Copy link
Contributor Author

meganrogge commented Dec 9, 2022

@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:

constructor(
@INativeHostService private readonly nativeHostService: INativeHostService,
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IStorageService private storageService: IStorageService
) {
super();
// register listener with the OS
this._register(this.nativeHostService.onDidChangeColorScheme(scheme => this.update(scheme)));
const initial = this.getStoredValue() ?? environmentService.window.colorScheme;
this.dark = initial.dark;
this.highContrast = initial.highContrast;
// fetch the actual value from the OS
this.nativeHostService.getOSColorScheme().then(scheme => this.update(scheme));
}
private getStoredValue(): IColorScheme | undefined {
const stored = this.storageService.get(NativeHostColorSchemeService.STORAGE_KEY, StorageScope.APPLICATION);
if (stored) {
try {
const scheme = JSON.parse(stored);
if (isObject(scheme) && isBoolean(scheme.highContrast) && isBoolean(scheme.dark)) {
return scheme as IColorScheme;
}
} catch (e) {
// ignore
}
}
return undefined;
}

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

@bpasero
Copy link
Member

bpasero commented Dec 9, 2022

@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?

@meganrogge
Copy link
Contributor Author

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

@meganrogge
Copy link
Contributor Author

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

@bpasero
Copy link
Member

bpasero commented Dec 9, 2022

@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.

@meganrogge
Copy link
Contributor Author

It does appear to be working for me now

@meganrogge
Copy link
Contributor Author

meganrogge commented Dec 9, 2022

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

Think I see what's wrong though

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

You do not need the changes in argv.ts if you add the property to INativeWindowConfiguration:

export interface INativeWindowConfiguration extends IWindowConfiguration, NativeParsedArgs, ISandboxConfiguration {

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

We still need to somewhere read the accessibilitySupport value in the workbench, no?

@meganrogge
Copy link
Contributor Author

@bpasero it was already on INativeWindowConfiguration

@meganrogge
Copy link
Contributor Author

that already happens here

this.setAccessibilitySupport(environmentService.window.accessibilitySupport ? AccessibilitySupport.Enabled : AccessibilitySupport.Disabled);

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

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

Cool!

@meganrogge meganrogge merged commit bcdd9ab into main Dec 12, 2022
@meganrogge meganrogge deleted the merogge/reload-acc-mode branch December 12, 2022 20:23
@meganrogge
Copy link
Contributor Author

Thanks for the help @bpasero 👍🏼

@github-actions github-actions bot locked and limited conversation to collaborators Jan 26, 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.

NVDA is not recognized on Windows After Reload Of VS Code
3 participants