提交 ffa0993c 编写于 作者: J Johannes Rieken

fix #56245

上级 e6d95f46
......@@ -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
}
......@@ -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
}
......@@ -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<any>(
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());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册