提交 1c039f6d 编写于 作者: B Benjamin Pasero

💄 main entries

上级 98bdf8c5
......@@ -25,6 +25,7 @@ import { Schemas } from 'vs/base/common/network';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { onUnexpectedError } from 'vs/base/common/errors';
import * as browser from 'vs/base/browser/browser';
import { URI } from 'vs/base/common/uri';
import { IWorkspaceInitializationPayload } from 'vs/platform/workspaces/common/workspaces';
import { WorkspaceService } from 'vs/workbench/services/configuration/browser/configurationService';
......@@ -47,7 +48,7 @@ import { toLocalISOString } from 'vs/base/common/date';
import { IndexedDBLogProvider } from 'vs/workbench/services/log/browser/indexedDBLogProvider';
import { InMemoryLogProvider } from 'vs/workbench/services/log/common/inMemoryLogProvider';
class CodeRendererMain extends Disposable {
class BrowserMain extends Disposable {
constructor(
private readonly domElement: HTMLElement,
......@@ -72,6 +73,20 @@ class CodeRendererMain extends Disposable {
services.logService
);
// Listeners
this.registerListeners(workbench, services.storageService);
// Driver
if (this.configuration.driver) {
(async () => this._register(await registerWindowDriver()))();
}
// Startup
workbench.startup();
}
private registerListeners(workbench: Workbench, storageService: BrowserStorageService): void {
// Layout
this._register(addDisposableListener(window, EventType.RESIZE, () => workbench.layout()));
......@@ -82,24 +97,27 @@ class CodeRendererMain extends Disposable {
// Workbench Lifecycle
this._register(workbench.onBeforeShutdown(event => {
if (services.storageService.hasPendingUpdate) {
if (storageService.hasPendingUpdate) {
console.warn('Unload prevented: pending storage update');
event.veto(true); // prevent data loss from pending storage update
}
}));
this._register(workbench.onWillShutdown(() => {
services.storageService.close();
storageService.close();
this.saveBaseTheme();
}));
this._register(workbench.onShutdown(() => this.dispose()));
// Driver
if (this.configuration.driver) {
(async () => this._register(await registerWindowDriver()))();
}
// Startup
workbench.startup();
// Fullscreen
[EventType.FULLSCREEN_CHANGE, EventType.WK_FULLSCREEN_CHANGE].forEach(event => {
this._register(addDisposableListener(document, event, () => {
if (document.fullscreenElement || (<any>document).webkitFullscreenElement || (<any>document).webkitIsFullScreen) {
browser.setFullscreen(true);
} else {
browser.setFullscreen(false);
}
}));
});
}
private restoreBaseTheme(): void {
......@@ -291,7 +309,7 @@ class CodeRendererMain extends Disposable {
}
export function main(domElement: HTMLElement, options: IWorkbenchConstructionOptions): Promise<void> {
const renderer = new CodeRendererMain(domElement, options);
const renderer = new BrowserMain(domElement, options);
return renderer.open();
}
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import { URI } from 'vs/base/common/uri';
import * as browser from 'vs/base/browser/browser';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { Event } from 'vs/base/common/event';
import { ILogService } from 'vs/platform/log/common/log';
......@@ -13,7 +12,6 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import { IWindowService, IWindowsService } from 'vs/platform/windows/common/windows';
import { IRecentlyOpened, IRecent, isRecentFile, isRecentFolder } from 'vs/platform/history/common/history';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { addDisposableListener, EventType } from 'vs/base/browser/dom';
import { toStoreData, restoreRecentlyOpened } from 'vs/platform/history/common/historyStorage';
//#region Window
......@@ -34,7 +32,6 @@ export class SimpleWindowService extends Disposable implements IWindowService {
super();
this.addWorkspaceToRecentlyOpened();
this.registerListeners();
}
private addWorkspaceToRecentlyOpened(): void {
......@@ -49,24 +46,6 @@ export class SimpleWindowService extends Disposable implements IWindowService {
}
}
private registerListeners(): void {
this._register(addDisposableListener(document, EventType.FULLSCREEN_CHANGE, () => {
if (document.fullscreenElement || (<any>document).webkitFullscreenElement) {
browser.setFullscreen(true);
} else {
browser.setFullscreen(false);
}
}));
this._register(addDisposableListener(document, EventType.WK_FULLSCREEN_CHANGE, () => {
if (document.fullscreenElement || (<any>document).webkitFullscreenElement || (<any>document).webkitIsFullScreen) {
browser.setFullscreen(true);
} else {
browser.setFullscreen(false);
}
}));
}
async getRecentlyOpened(): Promise<IRecentlyOpened> {
const recentlyOpenedRaw = this.storageService.get(SimpleWindowService.RECENTLY_OPENED_KEY, StorageScope.GLOBAL);
if (recentlyOpenedRaw) {
......
......@@ -54,12 +54,13 @@ import { basename } from 'vs/base/common/resources';
import { IProductService } from 'vs/platform/product/common/productService';
import product from 'vs/platform/product/common/product';
class CodeRendererMain extends Disposable {
class DesktopMain extends Disposable {
private readonly environmentService: WorkbenchEnvironmentService;
constructor(configuration: IWindowConfiguration) {
super();
this.environmentService = new WorkbenchEnvironmentService(configuration, configuration.execPath);
this.init();
......@@ -113,18 +114,15 @@ class CodeRendererMain extends Disposable {
async open(): Promise<void> {
const services = await this.initServices();
await domContentLoaded();
mark('willStartWorkbench');
// Create Workbench
const workbench = new Workbench(document.body, services.serviceCollection, services.logService);
// Layout
this._register(addDisposableListener(window, EventType.RESIZE, e => this.onWindowResize(e, true, workbench)));
// Workbench Lifecycle
this._register(workbench.onShutdown(() => this.dispose()));
this._register(workbench.onWillShutdown(event => event.join(services.storageService.close())));
// Listeners
this.registerListeners(workbench, services.storageService);
// Startup
const instantiationService = workbench.startup();
......@@ -146,6 +144,16 @@ class CodeRendererMain extends Disposable {
services.logService.trace('workbench configuration', JSON.stringify(this.environmentService.configuration));
}
private registerListeners(workbench: Workbench, storageService: StorageService): void {
// Layout
this._register(addDisposableListener(window, EventType.RESIZE, e => this.onWindowResize(e, true, workbench)));
// Workbench Lifecycle
this._register(workbench.onShutdown(() => this.dispose()));
this._register(workbench.onWillShutdown(event => event.join(storageService.close())));
}
private onWindowResize(e: Event, retry: boolean, workbench: Workbench): void {
if (e.target === window) {
if (window.document && window.document.body && window.document.body.clientWidth === 0) {
......@@ -368,7 +376,7 @@ class CodeRendererMain extends Disposable {
}
export function main(configuration: IWindowConfiguration): Promise<void> {
const renderer = new CodeRendererMain(configuration);
const renderer = new DesktopMain(configuration);
return renderer.open();
}
......@@ -36,6 +36,12 @@ export class BrowserHostService extends Disposable implements IHostService {
) {
super();
this.registerListeners();
}
private registerListeners(): void {
// Track Focus on Window
const focusTracker = this._register(trackFocus(window));
this._onDidChangeFocus = Event.any(
Event.map(focusTracker.onDidFocus, () => this.hasFocus),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册