|
| 1 | +import { mainWindow } from 'vs/base/browser/window' |
1 | 2 | import type { IEditorOverrideServices } from 'vs/editor/standalone/browser/standaloneServices' |
| 3 | +import { IConfigurationService } from 'vs/platform/configuration/common/configuration.service' |
| 4 | +import { IDialogService } from 'vs/platform/dialogs/common/dialogs.service' |
| 5 | +import { IFileService } from 'vs/platform/files/common/files.service' |
2 | 6 | import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' |
3 | | -import { IHostService } from 'vs/workbench/services/host/browser/host.service' |
4 | | -import { IHostColorSchemeService } from 'vs/workbench/services/themes/common/hostColorSchemeService.service' |
| 7 | +import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' |
| 8 | +import { ILabelService } from 'vs/platform/label/common/label.service' |
| 9 | +import { ILayoutService } from 'vs/platform/layout/browser/layoutService.service' |
| 10 | +import { ILogService } from 'vs/platform/log/common/log.service' |
| 11 | +import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile.service' |
| 12 | +import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace.service' |
| 13 | +import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService.service' |
5 | 14 | import { BrowserHostService } from 'vs/workbench/services/host/browser/browserHostService' |
| 15 | +import { IHostService } from 'vs/workbench/services/host/browser/host.service' |
| 16 | +import type { BrowserLifecycleService } from 'vs/workbench/services/lifecycle/browser/lifecycleService' |
| 17 | +import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle.service' |
6 | 18 | import { BrowserHostColorSchemeService } from 'vs/workbench/services/themes/browser/browserHostColorSchemeService' |
| 19 | +import { IHostColorSchemeService } from 'vs/workbench/services/themes/common/hostColorSchemeService.service' |
| 20 | + |
| 21 | +class CustomBrowserHostService extends BrowserHostService { |
| 22 | + constructor( |
| 23 | + private _toggleFullScreen: () => Promise<void> | undefined, |
| 24 | + @ILayoutService layoutService: ILayoutService, |
| 25 | + @IConfigurationService configurationService: IConfigurationService, |
| 26 | + @IFileService fileService: IFileService, |
| 27 | + @ILabelService labelService: ILabelService, |
| 28 | + @IBrowserWorkbenchEnvironmentService environmentService: IBrowserWorkbenchEnvironmentService, |
| 29 | + @IInstantiationService instantiationService: IInstantiationService, |
| 30 | + @ILifecycleService lifecycleService: BrowserLifecycleService, |
| 31 | + @ILogService logService: ILogService, |
| 32 | + @IDialogService dialogService: IDialogService, |
| 33 | + @IWorkspaceContextService contextService: IWorkspaceContextService, |
| 34 | + @IUserDataProfilesService userDataProfilesService: IUserDataProfilesService |
| 35 | + ) { |
| 36 | + super( |
| 37 | + layoutService, |
| 38 | + configurationService, |
| 39 | + fileService, |
| 40 | + labelService, |
| 41 | + environmentService, |
| 42 | + instantiationService, |
| 43 | + lifecycleService, |
| 44 | + logService, |
| 45 | + dialogService, |
| 46 | + contextService, |
| 47 | + userDataProfilesService |
| 48 | + ) |
| 49 | + } |
7 | 50 |
|
8 | | -export default function getServiceOverride(): IEditorOverrideServices { |
| 51 | + override async toggleFullScreen(targetWindow: Window): Promise<void> { |
| 52 | + if (this._toggleFullScreen != null && targetWindow === mainWindow) { |
| 53 | + await this._toggleFullScreen() |
| 54 | + } else { |
| 55 | + await super.toggleFullScreen(targetWindow) |
| 56 | + } |
| 57 | + } |
| 58 | +} |
| 59 | + |
| 60 | +interface BrowserHostServiceOverrideParams { |
| 61 | + toggleFullScreen?: (targetWindow: Window) => Promise<void> |
| 62 | +} |
| 63 | + |
| 64 | +export default function getServiceOverride({ |
| 65 | + toggleFullScreen |
| 66 | +}: BrowserHostServiceOverrideParams = {}): IEditorOverrideServices { |
9 | 67 | return { |
10 | | - [IHostService.toString()]: new SyncDescriptor(BrowserHostService, [], true), |
| 68 | + [IHostService.toString()]: new SyncDescriptor( |
| 69 | + CustomBrowserHostService, |
| 70 | + [toggleFullScreen], |
| 71 | + true |
| 72 | + ), |
11 | 73 | [IHostColorSchemeService.toString()]: new SyncDescriptor( |
12 | 74 | BrowserHostColorSchemeService, |
13 | 75 | [], |
|
0 commit comments