mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3
This commit is contained in:
@@ -18,7 +18,8 @@ import { ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
|
||||
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
export class CloseCurrentWindowAction extends Action {
|
||||
|
||||
@@ -167,7 +168,7 @@ export abstract class BaseSwitchWindow extends Action {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
private electronEnvironmentService: IElectronEnvironmentService,
|
||||
private environmentService: INativeWorkbenchEnvironmentService,
|
||||
private quickInputService: IQuickInputService,
|
||||
private keybindingService: IKeybindingService,
|
||||
private modelService: IModelService,
|
||||
@@ -180,7 +181,7 @@ export abstract class BaseSwitchWindow extends Action {
|
||||
protected abstract isQuickNavigate(): boolean;
|
||||
|
||||
async run(): Promise<void> {
|
||||
const currentWindowId = this.electronEnvironmentService.windowId;
|
||||
const currentWindowId = this.environmentService.configuration.windowId;
|
||||
|
||||
const windows = await this.electronService.getWindows();
|
||||
const placeHolder = nls.localize('switchWindowPlaceHolder', "Select a window to switch to");
|
||||
@@ -222,14 +223,14 @@ export class SwitchWindow extends BaseSwitchWindow {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IElectronEnvironmentService electronEnvironmentService: IElectronEnvironmentService,
|
||||
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
|
||||
@IQuickInputService quickInputService: IQuickInputService,
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IElectronService electronService: IElectronService
|
||||
) {
|
||||
super(id, label, electronEnvironmentService, quickInputService, keybindingService, modelService, modeService, electronService);
|
||||
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
|
||||
}
|
||||
|
||||
protected isQuickNavigate(): boolean {
|
||||
@@ -245,14 +246,14 @@ export class QuickSwitchWindow extends BaseSwitchWindow {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IElectronEnvironmentService electronEnvironmentService: IElectronEnvironmentService,
|
||||
@IWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
|
||||
@IQuickInputService quickInputService: IQuickInputService,
|
||||
@IKeybindingService keybindingService: IKeybindingService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IElectronService electronService: IElectronService
|
||||
) {
|
||||
super(id, label, electronEnvironmentService, quickInputService, keybindingService, modelService, modeService, electronService);
|
||||
super(id, label, environmentService, quickInputService, keybindingService, modelService, modeService, electronService);
|
||||
}
|
||||
|
||||
protected isQuickNavigate(): boolean {
|
||||
|
||||
@@ -17,7 +17,7 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IsMacContext, HasMacNativeTabsContext } from 'vs/workbench/browser/contextkeys'; // {{SQL CARBON EDIT}} remove import
|
||||
import { IsMacContext } from 'vs/platform/contextkey/common/contextkeys';
|
||||
import { NoEditorsVisibleContext, SingleEditorGroupsContext } from 'vs/workbench/common/editor';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/platform/jsonschemas/common/jsonContributionRegistry';
|
||||
@@ -84,7 +84,7 @@ import { InstallVSIXAction } from 'vs/workbench/contrib/extensions/browser/exten
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
|
||||
command,
|
||||
when: HasMacNativeTabsContext
|
||||
when: ContextKeyExpr.equals('config.window.nativeTabs', 'true')
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
import * as fs from 'fs';
|
||||
import * as gracefulFs from 'graceful-fs';
|
||||
import { createHash } from 'crypto';
|
||||
import { webFrame } from 'electron';
|
||||
import { importEntries, mark } from 'vs/base/common/performance';
|
||||
import { Workbench } from 'vs/workbench/browser/workbench';
|
||||
import { ElectronWindow } from 'vs/workbench/electron-browser/window';
|
||||
import { NativeWindow } from 'vs/workbench/electron-browser/window';
|
||||
import { setZoomLevel, setZoomFactor, setFullscreen } from 'vs/base/browser/browser';
|
||||
import { domContentLoaded, addDisposableListener, EventType, scheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
@@ -20,8 +21,7 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { stat } from 'vs/base/node/pfs';
|
||||
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/nativeKeymapService';
|
||||
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { webFrame } from 'electron';
|
||||
import { INativeWindowConfiguration } from 'vs/platform/windows/node/window';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, reviveWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ConsoleLogService, MultiplexLogService, ILogService, ConsoleLogInMainService } from 'vs/platform/log/common/log';
|
||||
import { NativeStorageService } from 'vs/platform/storage/node/storageService';
|
||||
@@ -51,16 +51,15 @@ import { FileUserDataProvider } from 'vs/workbench/services/userData/common/file
|
||||
import { basename } from 'vs/base/common/resources';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { ElectronEnvironmentService, IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
|
||||
|
||||
class DesktopMain extends Disposable {
|
||||
|
||||
private readonly environmentService: NativeWorkbenchEnvironmentService;
|
||||
|
||||
constructor(private configuration: IWindowConfiguration) {
|
||||
constructor(private configuration: INativeWindowConfiguration) {
|
||||
super();
|
||||
|
||||
this.environmentService = new NativeWorkbenchEnvironmentService(configuration, configuration.execPath, configuration.windowId);
|
||||
this.environmentService = new NativeWorkbenchEnvironmentService(configuration, configuration.execPath);
|
||||
|
||||
this.init();
|
||||
}
|
||||
@@ -127,7 +126,7 @@ class DesktopMain extends Disposable {
|
||||
const instantiationService = workbench.startup();
|
||||
|
||||
// Window
|
||||
this._register(instantiationService.createInstance(ElectronWindow));
|
||||
this._register(instantiationService.createInstance(NativeWindow));
|
||||
|
||||
// Driver
|
||||
if (this.environmentService.configuration.driver) {
|
||||
@@ -180,11 +179,6 @@ class DesktopMain extends Disposable {
|
||||
|
||||
// Environment
|
||||
serviceCollection.set(IWorkbenchEnvironmentService, this.environmentService);
|
||||
serviceCollection.set(IElectronEnvironmentService, new ElectronEnvironmentService(
|
||||
this.configuration.windowId,
|
||||
this.environmentService.sharedIPCHandle,
|
||||
this.environmentService
|
||||
));
|
||||
|
||||
// Product
|
||||
serviceCollection.set(IProductService, { _serviceBrand: undefined, ...product });
|
||||
@@ -373,7 +367,7 @@ class DesktopMain extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
export function main(configuration: IWindowConfiguration): Promise<void> {
|
||||
export function main(configuration: INativeWindowConfiguration): Promise<void> {
|
||||
const renderer = new DesktopMain(configuration);
|
||||
|
||||
return renderer.open();
|
||||
|
||||
242
src/vs/workbench/electron-browser/parts/titlebar/titlebarPart.ts
Normal file
242
src/vs/workbench/electron-browser/parts/titlebar/titlebarPart.ts
Normal file
@@ -0,0 +1,242 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { isMacintosh, isWindows, isLinux } from 'vs/base/common/platform';
|
||||
import { IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { TitlebarPart as BrowserTitleBarPart } from 'vs/workbench/browser/parts/titlebar/titlebarPart';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { getTitleBarStyle } from 'vs/platform/windows/common/windows';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export class TitlebarPart extends BrowserTitleBarPart {
|
||||
private appIcon: HTMLElement | undefined;
|
||||
private windowControls: HTMLElement | undefined;
|
||||
private maxRestoreControl: HTMLElement | undefined;
|
||||
private dragRegion: HTMLElement | undefined;
|
||||
private resizer: HTMLElement | undefined;
|
||||
|
||||
constructor(
|
||||
@IContextMenuService contextMenuService: IContextMenuService,
|
||||
@IConfigurationService protected readonly configurationService: IConfigurationService,
|
||||
@IEditorService editorService: IEditorService,
|
||||
@IWorkbenchEnvironmentService protected readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IWorkspaceContextService contextService: IWorkspaceContextService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@ILabelService labelService: ILabelService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@IMenuService menuService: IMenuService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IProductService productService: IProductService,
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
) {
|
||||
super(contextMenuService, configurationService, editorService, environmentService, contextService, instantiationService, themeService, labelService, storageService, layoutService, menuService, contextKeyService, hostService, productService);
|
||||
}
|
||||
|
||||
private onUpdateAppIconDragBehavior() {
|
||||
const setting = this.configurationService.getValue('window.doubleClickIconToClose');
|
||||
if (setting && this.appIcon) {
|
||||
(this.appIcon.style as any)['-webkit-app-region'] = 'no-drag';
|
||||
} else if (this.appIcon) {
|
||||
(this.appIcon.style as any)['-webkit-app-region'] = 'drag';
|
||||
}
|
||||
}
|
||||
|
||||
private onDidChangeMaximized(maximized: boolean) {
|
||||
if (this.maxRestoreControl) {
|
||||
if (maximized) {
|
||||
DOM.removeClass(this.maxRestoreControl, 'codicon-chrome-maximize');
|
||||
DOM.addClass(this.maxRestoreControl, 'codicon-chrome-restore');
|
||||
} else {
|
||||
DOM.removeClass(this.maxRestoreControl, 'codicon-chrome-restore');
|
||||
DOM.addClass(this.maxRestoreControl, 'codicon-chrome-maximize');
|
||||
}
|
||||
}
|
||||
|
||||
if (this.resizer) {
|
||||
if (maximized) {
|
||||
DOM.hide(this.resizer);
|
||||
} else {
|
||||
DOM.show(this.resizer);
|
||||
}
|
||||
}
|
||||
|
||||
this.adjustTitleMarginToCenter();
|
||||
}
|
||||
|
||||
private onMenubarFocusChanged(focused: boolean) {
|
||||
if ((isWindows || isLinux) && this.currentMenubarVisibility !== 'compact' && this.dragRegion) {
|
||||
if (focused) {
|
||||
DOM.hide(this.dragRegion);
|
||||
} else {
|
||||
DOM.show(this.dragRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected onMenubarVisibilityChanged(visible: boolean) {
|
||||
// Hide title when toggling menu bar
|
||||
if ((isWindows || isLinux) && this.currentMenubarVisibility === 'toggle' && visible) {
|
||||
// Hack to fix issue #52522 with layered webkit-app-region elements appearing under cursor
|
||||
if (this.dragRegion) {
|
||||
DOM.hide(this.dragRegion);
|
||||
setTimeout(() => DOM.show(this.dragRegion!), 50);
|
||||
}
|
||||
}
|
||||
|
||||
super.onMenubarVisibilityChanged(visible);
|
||||
}
|
||||
|
||||
protected onConfigurationChanged(event: IConfigurationChangeEvent): void {
|
||||
|
||||
super.onConfigurationChanged(event);
|
||||
|
||||
if (event.affectsConfiguration('window.doubleClickIconToClose')) {
|
||||
if (this.appIcon) {
|
||||
this.onUpdateAppIconDragBehavior();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected adjustTitleMarginToCenter(): void {
|
||||
if (this.customMenubar && this.menubar) {
|
||||
const leftMarker = (this.appIcon ? this.appIcon.clientWidth : 0) + this.menubar.clientWidth + 10;
|
||||
const rightMarker = this.element.clientWidth - (this.windowControls ? this.windowControls.clientWidth : 0) - 10;
|
||||
|
||||
// Not enough space to center the titlebar within window,
|
||||
// Center between menu and window controls
|
||||
if (leftMarker > (this.element.clientWidth - this.title.clientWidth) / 2 ||
|
||||
rightMarker < (this.element.clientWidth + this.title.clientWidth) / 2) {
|
||||
this.title.style.position = '';
|
||||
this.title.style.left = '';
|
||||
this.title.style.transform = '';
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.title.style.position = 'absolute';
|
||||
this.title.style.left = '50%';
|
||||
this.title.style.transform = 'translate(-50%, 0)';
|
||||
}
|
||||
|
||||
protected installMenubar(): void {
|
||||
super.installMenubar();
|
||||
|
||||
if (this.menubar) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.customMenubar) {
|
||||
this._register(this.customMenubar.onFocusStateChange(e => this.onMenubarFocusChanged(e)));
|
||||
}
|
||||
}
|
||||
|
||||
createContentArea(parent: HTMLElement): HTMLElement {
|
||||
const ret = super.createContentArea(parent);
|
||||
|
||||
// App Icon (Native Windows/Linux)
|
||||
if (!isMacintosh) {
|
||||
this.appIcon = DOM.prepend(this.element, DOM.$('div.window-appicon'));
|
||||
this.onUpdateAppIconDragBehavior();
|
||||
|
||||
this._register(DOM.addDisposableListener(this.appIcon, DOM.EventType.DBLCLICK, (e => {
|
||||
this.electronService.closeWindow();
|
||||
})));
|
||||
}
|
||||
|
||||
// Draggable region that we can manipulate for #52522
|
||||
this.dragRegion = DOM.prepend(this.element, DOM.$('div.titlebar-drag-region'));
|
||||
|
||||
// Window Controls (Native Windows/Linux)
|
||||
if (!isMacintosh) {
|
||||
this.windowControls = DOM.append(this.element, DOM.$('div.window-controls-container'));
|
||||
|
||||
// Minimize
|
||||
const minimizeIcon = DOM.append(this.windowControls, DOM.$('div.window-icon.window-minimize.codicon.codicon-chrome-minimize'));
|
||||
this._register(DOM.addDisposableListener(minimizeIcon, DOM.EventType.CLICK, e => {
|
||||
this.electronService.minimizeWindow();
|
||||
}));
|
||||
|
||||
// Restore
|
||||
this.maxRestoreControl = DOM.append(this.windowControls, DOM.$('div.window-icon.window-max-restore.codicon'));
|
||||
this._register(DOM.addDisposableListener(this.maxRestoreControl, DOM.EventType.CLICK, async e => {
|
||||
const maximized = await this.electronService.isMaximized();
|
||||
if (maximized) {
|
||||
return this.electronService.unmaximizeWindow();
|
||||
}
|
||||
|
||||
return this.electronService.maximizeWindow();
|
||||
}));
|
||||
|
||||
// Close
|
||||
const closeIcon = DOM.append(this.windowControls, DOM.$('div.window-icon.window-close.codicon.codicon-chrome-close'));
|
||||
this._register(DOM.addDisposableListener(closeIcon, DOM.EventType.CLICK, e => {
|
||||
this.electronService.closeWindow();
|
||||
}));
|
||||
|
||||
// Resizer
|
||||
this.resizer = DOM.append(this.element, DOM.$('div.resizer'));
|
||||
|
||||
this._register(this.layoutService.onMaximizeChange(maximized => this.onDidChangeMaximized(maximized)));
|
||||
this.onDidChangeMaximized(this.layoutService.isWindowMaximized());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
updateLayout(dimension: DOM.Dimension): void {
|
||||
this.lastLayoutDimensions = dimension;
|
||||
|
||||
if (getTitleBarStyle(this.configurationService, this.environmentService) === 'custom') {
|
||||
// Only prevent zooming behavior on macOS or when the menubar is not visible
|
||||
if (isMacintosh || this.currentMenubarVisibility === 'hidden') {
|
||||
this.title.style.zoom = `${1 / browser.getZoomFactor()}`;
|
||||
if (isWindows || isLinux) {
|
||||
if (this.appIcon) {
|
||||
this.appIcon.style.zoom = `${1 / browser.getZoomFactor()}`;
|
||||
}
|
||||
|
||||
if (this.windowControls) {
|
||||
this.windowControls.style.zoom = `${1 / browser.getZoomFactor()}`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.title.style.zoom = null;
|
||||
if (isWindows || isLinux) {
|
||||
if (this.appIcon) {
|
||||
this.appIcon.style.zoom = null;
|
||||
}
|
||||
|
||||
if (this.windowControls) {
|
||||
this.windowControls.style.zoom = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DOM.runAtThisOrScheduleAtNextAnimationFrame(() => this.adjustTitleMarginToCenter());
|
||||
|
||||
if (this.customMenubar) {
|
||||
const menubarDimension = new DOM.Dimension(0, dimension.height);
|
||||
this.customMenubar.layout(menubarDimension);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,20 +6,20 @@
|
||||
import * as nls from 'vs/nls';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import { equals, deepClone, assign } from 'vs/base/common/objects';
|
||||
import { equals, deepClone } from 'vs/base/common/objects';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { toResource, IUntitledTextResourceInput, SideBySideEditor, pathsToEditors } from 'vs/workbench/common/editor';
|
||||
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { toResource, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors } from 'vs/workbench/common/editor';
|
||||
import { IEditorService, IResourceEditorInputType } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ITelemetryService, crashReporterIdStorageKey } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWindowSettings, IOpenFileRequest, IWindowsConfiguration, IAddFoldersRequest, IRunActionInWindowRequest, IRunKeybindingInWindowRequest, getTitleBarStyle } from 'vs/platform/windows/common/windows';
|
||||
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
|
||||
import { IWorkbenchThemeService, VS_HC_THEME } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { ICommandService, CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
|
||||
import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/nativeKeymapService';
|
||||
import { ipcRenderer as ipc, webFrame, crashReporter, CrashReporterStartOptions, Event as IpcEvent } from 'electron';
|
||||
import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing';
|
||||
@@ -46,7 +46,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
||||
import { MenubarControl } from '../browser/parts/titlebar/menubarControl';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IUpdateService } from 'vs/platform/update/common/update';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
|
||||
import { IPreferencesService } from '../services/preferences/common/preferences';
|
||||
import { IMenubarService, IMenubarData, IMenubarMenu, IMenubarKeybinding, IMenubarMenuItemSubmenu, IMenubarMenuItemAction, MenubarMenuItem } from 'vs/platform/menubar/node/menubar';
|
||||
import { withNullAsUndefined, assertIsDefined } from 'vs/base/common/types';
|
||||
@@ -58,12 +58,13 @@ import { getBaseLabel } from 'vs/base/common/labels';
|
||||
import { ITunnelService, extractLocalHostUriMetaDataForPortMapping } from 'vs/platform/remote/common/tunnel';
|
||||
import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IElectronEnvironmentService } from 'vs/workbench/services/electron/electron-browser/electronEnvironmentService';
|
||||
import { IWorkingCopyService, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { AutoSaveMode, IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService';
|
||||
import { clearAllFontInfos } from 'vs/editor/browser/config/configuration';
|
||||
|
||||
export class ElectronWindow extends Disposable {
|
||||
export class NativeWindow extends Disposable {
|
||||
|
||||
private touchBarMenu: IMenu | undefined;
|
||||
private readonly touchBarDisposables = this._register(new DisposableStore());
|
||||
@@ -94,7 +95,7 @@ export class ElectronWindow extends Disposable {
|
||||
@IMenuService private readonly menuService: IMenuService,
|
||||
@ILifecycleService private readonly lifecycleService: ILifecycleService,
|
||||
@IIntegrityService private readonly integrityService: IIntegrityService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
|
||||
@IAccessibilityService private readonly accessibilityService: IAccessibilityService,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@@ -102,9 +103,9 @@ export class ElectronWindow extends Disposable {
|
||||
@IElectronService private readonly electronService: IElectronService,
|
||||
@ITunnelService private readonly tunnelService: ITunnelService,
|
||||
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
|
||||
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService,
|
||||
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService,
|
||||
@IStorageService private readonly storageService: IStorageService,
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -180,6 +181,10 @@ export class ElectronWindow extends Disposable {
|
||||
this.notificationService.info(message);
|
||||
});
|
||||
|
||||
ipc.on('vscode:displayChanged', (event: IpcEvent) => {
|
||||
clearAllFontInfos();
|
||||
});
|
||||
|
||||
// Fullscreen Events
|
||||
ipc.on('vscode:enterFullScreen', async () => {
|
||||
await this.lifecycleService.when(LifecyclePhase.Ready);
|
||||
@@ -280,8 +285,8 @@ export class ElectronWindow extends Disposable {
|
||||
|
||||
// Detect minimize / maximize
|
||||
this._register(Event.any(
|
||||
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.electronEnvironmentService.windowId), () => true),
|
||||
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.electronEnvironmentService.windowId), () => false)
|
||||
Event.map(Event.filter(this.electronService.onWindowMaximize, id => id === this.environmentService.configuration.windowId), () => true),
|
||||
Event.map(Event.filter(this.electronService.onWindowUnmaximize, id => id === this.environmentService.configuration.windowId), () => false)
|
||||
)(e => this.onDidChangeMaximized(e)));
|
||||
|
||||
this.onDidChangeMaximized(this.environmentService.configuration.maximized ?? false);
|
||||
@@ -304,8 +309,8 @@ export class ElectronWindow extends Disposable {
|
||||
// Close when empty: check if we should close the window based on the setting
|
||||
// Overruled by: window has a workspace opened or this window is for extension development
|
||||
// or setting is disabled. Also enabled when running with --wait from the command line.
|
||||
const visibleEditors = this.editorService.visibleControls;
|
||||
if (visibleEditors.length === 0 && this.contextService.getWorkbenchState() === WorkbenchState.EMPTY && !this.environmentService.isExtensionDevelopment) {
|
||||
const visibleEditorPanes = this.editorService.visibleEditorPanes;
|
||||
if (visibleEditorPanes.length === 0 && this.contextService.getWorkbenchState() === WorkbenchState.EMPTY && !this.environmentService.isExtensionDevelopment) {
|
||||
const closeWhenEmpty = this.configurationService.getValue<boolean>('window.closeWhenEmpty');
|
||||
if (closeWhenEmpty || this.environmentService.args.wait) {
|
||||
this.closeEmptyWindowScheduler.schedule();
|
||||
@@ -314,8 +319,8 @@ export class ElectronWindow extends Disposable {
|
||||
}
|
||||
|
||||
private onAllEditorsClosed(): void {
|
||||
const visibleEditors = this.editorService.visibleControls.length;
|
||||
if (visibleEditors === 0) {
|
||||
const visibleEditorPanes = this.editorService.visibleEditorPanes.length;
|
||||
if (visibleEditorPanes === 0) {
|
||||
this.electronService.closeWindow();
|
||||
}
|
||||
}
|
||||
@@ -395,7 +400,7 @@ export class ElectronWindow extends Disposable {
|
||||
this.setupOpenHandlers();
|
||||
|
||||
// Emit event when vscode is ready
|
||||
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipc.send('vscode:workbenchReady', this.electronEnvironmentService.windowId));
|
||||
this.lifecycleService.when(LifecyclePhase.Ready).then(() => ipc.send('vscode:workbenchReady', this.environmentService.configuration.windowId));
|
||||
|
||||
// Integrity warning
|
||||
this.integrityService.isPure().then(res => this.titleService.updateProperties({ isPure: res.isPure }));
|
||||
@@ -422,8 +427,8 @@ export class ElectronWindow extends Disposable {
|
||||
this.updateTouchbarMenu();
|
||||
|
||||
// Crash reporter (if enabled)
|
||||
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.hockeyApp && this.configurationService.getValue('telemetry.enableCrashReporter')) {
|
||||
this.setupCrashReporter(product.crashReporter.companyName, product.crashReporter.productName, product.hockeyApp);
|
||||
if (!this.environmentService.disableCrashReporter && product.crashReporter && product.appCenter && this.configurationService.getValue('telemetry.enableCrashReporter')) {
|
||||
this.setupCrashReporter(product.crashReporter.companyName, product.crashReporter.productName, product.appCenter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -536,31 +541,36 @@ export class ElectronWindow extends Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private async setupCrashReporter(companyName: string, productName: string, hockeyAppConfig: typeof product.hockeyApp): Promise<void> {
|
||||
if (!hockeyAppConfig) {
|
||||
private async setupCrashReporter(companyName: string, productName: string, appCenterConfig: typeof product.appCenter): Promise<void> {
|
||||
if (!appCenterConfig) {
|
||||
return;
|
||||
}
|
||||
|
||||
const appCenterURL = isWindows ? appCenterConfig[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64']
|
||||
: isLinux ? appCenterConfig[`linux-x64`] : appCenterConfig.darwin;
|
||||
const info = await this.telemetryService.getTelemetryInfo();
|
||||
const crashReporterId = this.storageService.get(crashReporterIdStorageKey, StorageScope.GLOBAL)!;
|
||||
|
||||
// base options with product info
|
||||
const options: CrashReporterStartOptions = {
|
||||
companyName,
|
||||
productName,
|
||||
submitURL: isWindows ? hockeyAppConfig[process.arch === 'ia32' ? 'win32-ia32' : 'win32-x64'] : isLinux ? hockeyAppConfig[`linux-x64`] : hockeyAppConfig.darwin,
|
||||
submitURL: appCenterURL.concat('&uid=', crashReporterId, '&iid=', crashReporterId, '&sid=', info.sessionId),
|
||||
extra: {
|
||||
vscode_version: product.version,
|
||||
vscode_commit: product.commit || ''
|
||||
}
|
||||
};
|
||||
|
||||
// mixin telemetry info
|
||||
const info = await this.telemetryService.getTelemetryInfo();
|
||||
assign(options.extra, { vscode_sessionId: info.sessionId });
|
||||
// start crash reporter in the main process first.
|
||||
// On windows crashpad excepts a name pipe for the client to connect,
|
||||
// this pipe is created by crash reporter initialization from the main process,
|
||||
// changing this order of initialization will cause issues.
|
||||
// For more info: https://chromium.googlesource.com/crashpad/crashpad/+/HEAD/doc/overview_design.md#normal-registration
|
||||
await this.electronService.startCrashReporter(options);
|
||||
|
||||
// start crash reporter right here
|
||||
crashReporter.start(deepClone(options));
|
||||
|
||||
// start crash reporter in the main process
|
||||
return this.electronService.startCrashReporter(options);
|
||||
}
|
||||
|
||||
private onAddFoldersRequest(request: IAddFoldersRequest): void {
|
||||
@@ -587,7 +597,7 @@ export class ElectronWindow extends Disposable {
|
||||
}
|
||||
|
||||
private async onOpenFiles(request: IOpenFileRequest): Promise<void> {
|
||||
const inputs: IResourceEditor[] = [];
|
||||
const inputs: IResourceEditorInputType[] = [];
|
||||
const diffMode = !!(request.filesToDiff && (request.filesToDiff.length === 2));
|
||||
|
||||
if (!diffMode && request.filesToOpenOrCreate) {
|
||||
@@ -667,7 +677,7 @@ export class ElectronWindow extends Disposable {
|
||||
});
|
||||
}
|
||||
|
||||
private async openResources(resources: Array<IResourceInput | IUntitledTextResourceInput>, diffMode: boolean): Promise<unknown> {
|
||||
private async openResources(resources: Array<IResourceEditorInput | IUntitledTextResourceEditorInput>, diffMode: boolean): Promise<unknown> {
|
||||
await this.lifecycleService.when(LifecyclePhase.Ready);
|
||||
|
||||
// In diffMode we open 2 resources as diff
|
||||
@@ -697,11 +707,10 @@ class NativeMenubarControl extends MenubarControl {
|
||||
@IStorageService storageService: IStorageService,
|
||||
@INotificationService notificationService: INotificationService,
|
||||
@IPreferencesService preferencesService: IPreferencesService,
|
||||
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
|
||||
@IWorkbenchEnvironmentService protected readonly environmentService: INativeWorkbenchEnvironmentService,
|
||||
@IAccessibilityService accessibilityService: IAccessibilityService,
|
||||
@IMenubarService private readonly menubarService: IMenubarService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IElectronEnvironmentService private readonly electronEnvironmentService: IElectronEnvironmentService
|
||||
) {
|
||||
super(
|
||||
menuService,
|
||||
@@ -750,7 +759,7 @@ class NativeMenubarControl extends MenubarControl {
|
||||
// Send menus to main process to be rendered by Electron
|
||||
const menubarData = { menus: {}, keybindings: {} };
|
||||
if (this.getMenubarMenus(menubarData)) {
|
||||
this.menubarService.updateMenubar(this.electronEnvironmentService.windowId, menubarData);
|
||||
this.menubarService.updateMenubar(this.environmentService.configuration.windowId, menubarData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user