From ffa0993cb2d0dccb9de590617bfbe4757ef5f664 Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 11 Sep 2018 16:01:17 +0200 Subject: [PATCH] fix #56245 --- src/vs/base/browser/browser.ts | 6 +-- .../electron-browser/workbench/workbench.js | 23 ++++++----- .../partsSplash.contribution.ts | 39 ++++++++++++------- 3 files changed, 37 insertions(+), 31 deletions(-) diff --git a/src/vs/base/browser/browser.ts b/src/vs/base/browser/browser.ts index 1c694eeac3f..772f12ef04b 100644 --- a/src/vs/base/browser/browser.ts +++ b/src/vs/base/browser/browser.ts @@ -125,9 +125,7 @@ export function setFullscreen(fullscreen: boolean): void { export function isFullscreen(): boolean { return WindowManager.INSTANCE.isFullscreen(); } -export function onDidChangeFullscreen(callback: () => void): IDisposable { - return WindowManager.INSTANCE.onDidChangeFullscreen(callback); -} +export const onDidChangeFullscreen = WindowManager.INSTANCE.onDidChangeFullscreen; export function setAccessibilitySupport(accessibilitySupport: Platform.AccessibilitySupport): void { WindowManager.INSTANCE.setAccessibilitySupport(accessibilitySupport); @@ -168,4 +166,4 @@ export function hasClipboardSupport() { } return true; -} \ No newline at end of file +} diff --git a/src/vs/code/electron-browser/workbench/workbench.js b/src/vs/code/electron-browser/workbench/workbench.js index daf601e7425..c94646d2163 100644 --- a/src/vs/code/electron-browser/workbench/workbench.js +++ b/src/vs/code/electron-browser/workbench/workbench.js @@ -71,19 +71,21 @@ function showPartsSplash(configuration) { data = void 0; } + // minimal color configuration (works with or without persisted data) + const baseTheme = data ? data.baseTheme : configuration.highContrast ? 'hc-black' : 'vs-dark'; + const shellBackground = data ? data.colorInfo.editorBackground : configuration.highContrast ? '#000000' : '#1E1E1E'; + const shellForeground = data ? data.colorInfo.foreground : configuration.highContrast ? '#FFFFFF' : '#CCCCCC'; const style = document.createElement('style'); document.head.appendChild(style); + document.body.className = `monaco-shell ${baseTheme}`; + style.innerHTML = `.monaco-shell { background-color: ${shellBackground}; color: ${shellForeground}; }`; - if (data) { - const { layoutInfo, colorInfo, baseTheme } = data; - - // set the theme base id used by images and some styles - document.body.className = `monaco-shell ${baseTheme}`; - // stylesheet that defines foreground and background color - style.innerHTML = `.monaco-shell { background-color: ${colorInfo.editorBackground}; color: ${colorInfo.foreground}; }`; + if (data && data.layoutInfo) { + // restore parts if possible (we might not always store layout info) + const { id, layoutInfo, colorInfo } = data; const splash = document.createElement('div'); - splash.id = data.id; + splash.id = id; // ensure there is enough space layoutInfo.sideBarWidth = Math.min(layoutInfo.sideBarWidth, window.innerWidth - (layoutInfo.activityBarWidth + layoutInfo.editorPartMinWidth)); @@ -105,9 +107,6 @@ function showPartsSplash(configuration) { `; } document.body.appendChild(splash); - } else { - document.body.className = `monaco-shell ${configuration.highContrast ? 'hc-black' : 'vs-dark'}`; - style.innerHTML = `.monaco-shell { background-color: ${configuration.highContrast ? '#000000' : '#1E1E1E'}; color: ${configuration.highContrast ? '#FFFFFF' : '#CCCCCC'}; }`; } perf.mark('didShowPartsSplash'); @@ -134,4 +133,4 @@ function getLazyEnv() { ipc.send('vscode:fetchShellEnv'); }); -} \ No newline at end of file +} diff --git a/src/vs/workbench/parts/splash/electron-browser/partsSplash.contribution.ts b/src/vs/workbench/parts/splash/electron-browser/partsSplash.contribution.ts index 5f76b802ea5..67d65ca7f7c 100644 --- a/src/vs/workbench/parts/splash/electron-browser/partsSplash.contribution.ts +++ b/src/vs/workbench/parts/splash/electron-browser/partsSplash.contribution.ts @@ -5,20 +5,21 @@ 'use strict'; +import { onDidChangeFullscreen, isFullscreen } from 'vs/base/browser/browser'; import { getTotalHeight, getTotalWidth } from 'vs/base/browser/dom'; +import { Color } from 'vs/base/common/color'; +import { anyEvent, debounceEvent } from 'vs/base/common/event'; +import { dispose, IDisposable } from 'vs/base/common/lifecycle'; +import { IBroadcastService } from 'vs/platform/broadcast/electron-browser/broadcastService'; import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle'; import { Registry } from 'vs/platform/registry/common/platform'; import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage'; -import { IThemeService, getThemeTypeSelector } from 'vs/platform/theme/common/themeService'; -import { IBroadcastService } from 'vs/platform/broadcast/electron-browser/broadcastService'; +import { ColorIdentifier, editorBackground, foreground } from 'vs/platform/theme/common/colorRegistry'; +import { getThemeTypeSelector, IThemeService } from 'vs/platform/theme/common/themeService'; +import { DEFAULT_EDITOR_MIN_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor'; import { Extensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions'; import * as themes from 'vs/workbench/common/theme'; import { IPartService, Parts, Position } from 'vs/workbench/services/part/common/partService'; -import { IDisposable, dispose } from 'vs/base/common/lifecycle'; -import { debounceEvent } from 'vs/base/common/event'; -import { DEFAULT_EDITOR_MIN_DIMENSIONS } from 'vs/workbench/browser/parts/editor/editor'; -import { ColorIdentifier, editorBackground, foreground } from 'vs/platform/theme/common/colorRegistry'; -import { Color } from 'vs/base/common/color'; class PartsSplash { @@ -26,8 +27,8 @@ class PartsSplash { private readonly _disposables: IDisposable[] = []; - private lastBaseTheme: string; - private lastBackground: string; + private _lastBaseTheme: string; + private _lastBackground: string; constructor( @IThemeService private readonly _themeService: IThemeService, @@ -37,7 +38,10 @@ class PartsSplash { @IBroadcastService private broadcastService: IBroadcastService ) { lifecycleService.when(LifecyclePhase.Running).then(_ => this._removePartsSplash()); - debounceEvent(_partService.onEditorLayout, () => { }, 50)(this._savePartsSplash, this, this._disposables); + debounceEvent(anyEvent( + onDidChangeFullscreen, + _partService.onEditorLayout + ), () => { }, 150)(this._savePartsSplash, this, this._disposables); } dispose(): void { @@ -55,7 +59,7 @@ class PartsSplash { statusBarBackground: this._getThemeColor(themes.STATUS_BAR_BACKGROUND), statusBarNoFolderBackground: this._getThemeColor(themes.STATUS_BAR_NO_FOLDER_BACKGROUND), }; - const layoutInfo = { + const layoutInfo = isFullscreen() ? undefined : { sideBarSide: this._partService.getSideBarPosition() === Position.RIGHT ? 'right' : 'left', editorPartMinWidth: DEFAULT_EDITOR_MIN_DIMENSIONS.width, titleBarHeight: getTotalHeight(this._partService.getContainer(Parts.TITLEBAR_PART)), @@ -63,12 +67,17 @@ class PartsSplash { sideBarWidth: getTotalWidth(this._partService.getContainer(Parts.SIDEBAR_PART)), statusBarHeight: getTotalHeight(this._partService.getContainer(Parts.STATUSBAR_PART)), }; - this._storageService.store('parts-splash-data', JSON.stringify({ id: PartsSplash._splashElementId, colorInfo, layoutInfo, baseTheme }), StorageScope.GLOBAL); + this._storageService.store('parts-splash-data', JSON.stringify({ + id: PartsSplash._splashElementId, + colorInfo, + layoutInfo, + baseTheme + }), StorageScope.GLOBAL); - if (baseTheme !== this.lastBaseTheme || colorInfo.editorBackground !== this.lastBackground) { + if (baseTheme !== this._lastBaseTheme || colorInfo.editorBackground !== this._lastBackground) { // notify the main window on background color changes: the main window sets the background color to new windows - this.lastBaseTheme = baseTheme; - this.lastBackground = colorInfo.editorBackground; + this._lastBaseTheme = baseTheme; + this._lastBackground = colorInfo.editorBackground; // the color needs to be in hex const backgroundColor = this._themeService.getTheme().getColor(editorBackground) || themes.WORKBENCH_BACKGROUND(this._themeService.getTheme());