提交 a24a9238 编写于 作者: B Benjamin Pasero

OS X - When quitting in fullscreen mode, it should reopen in full screen mode (fixes #1491)

上级 bbdeeb99
......@@ -50,7 +50,7 @@ export class LinuxAutoUpdaterImpl extends EventEmitter {
this.emit('checking-for-update');
const proxyUrl = this.settingsService.getValue('http.proxy');
const proxyUrl = this.settingsService.getValue<string>('http.proxy');
const strictSSL = this.settingsService.getValue('http.proxyStrictSSL', true);
const agent = getProxyAgent(this.url, { proxyUrl, strictSSL });
......
......@@ -64,7 +64,7 @@ export class Win32AutoUpdaterImpl extends EventEmitter {
this.emit('checking-for-update');
const proxyUrl = this.settingsService.getValue('http.proxy');
const proxyUrl = this.settingsService.getValue<string>('http.proxy');
const strictSSL = this.settingsService.getValue('http.proxyStrictSSL', true);
const agent = getProxyAgent(this.url, { proxyUrl, strictSSL });
......
......@@ -17,7 +17,7 @@ export interface ISettingsService {
serviceId: ServiceIdentifier<any>;
globalSettings: ISettings;
loadSync(): boolean;
getValue(key: string, fallback?: any): any;
getValue<T>(key: string, fallback?: T): T;
onChange: Event<ISettings>;
}
......
......@@ -230,7 +230,7 @@ export class UpdateManager extends EventEmitter implements IUpdateService {
}
private getUpdateChannel(): string {
const channel = this.settingsService.getValue('update.channel') || 'default';
const channel = this.settingsService.getValue<string>('update.channel') || 'default';
return channel === 'none' ? null : this.envService.quality;
}
......
......@@ -25,12 +25,14 @@ export interface IWindowState {
export interface IWindowCreationOptions {
state: IWindowState;
extensionDevelopmentPath?: string;
allowFullscreen?: boolean;
}
export enum WindowMode {
Maximized,
Normal,
Minimized
Minimized,
Fullscreen
}
export const defaultWindowState = function (mode = WindowMode.Normal): IWindowState {
......@@ -139,6 +141,7 @@ export class VSCodeWindow {
private static MIN_WIDTH = 200;
private static MIN_HEIGHT = 120;
private options: IWindowCreationOptions;
private showTimeoutHandle: any;
private _id: number;
private _win: Electron.BrowserWindow;
......@@ -159,6 +162,7 @@ export class VSCodeWindow {
@IEnvironmentService private envService: IEnvironmentService,
@IStorageService private storageService: IStorageService
) {
this.options = config;
this._lastFocusTime = -1;
this._readyState = ReadyState.NONE;
this._extensionDevelopmentPath = config.extensionDevelopmentPath;
......@@ -169,11 +173,13 @@ export class VSCodeWindow {
// For VS theme we can show directly because background is white
const usesLightTheme = /vs($| )/.test(this.storageService.getItem<string>(VSCodeWindow.themeStorageKey));
let showDirectly = true; // set to false to prevent background color flash (flash should be fixed for Electron >= 0.37.x)
if (showDirectly && !global.windowShow) {
if (!global.windowShow) {
global.windowShow = Date.now();
}
// in case we are maximized or fullscreen, only show later after the call to maximize/fullscreen (see below)
const isFullscreenOrMaximized = (this.currentWindowMode === WindowMode.Maximized || this.currentWindowMode === WindowMode.Fullscreen);
let options: Electron.BrowserWindowOptions = {
width: this.windowState.width,
height: this.windowState.height,
......@@ -182,7 +188,7 @@ export class VSCodeWindow {
backgroundColor: usesLightTheme ? '#FFFFFF' : platform.isMacintosh ? '#131313' : '#1E1E1E', // https://github.com/electron/electron/issues/5150
minWidth: VSCodeWindow.MIN_WIDTH,
minHeight: VSCodeWindow.MIN_HEIGHT,
show: showDirectly && this.currentWindowMode !== WindowMode.Maximized, // in case we are maximized, only show later after the call to maximize (see below)
show: !isFullscreenOrMaximized,
title: this.envService.product.nameLong,
webPreferences: {
'backgroundThrottling': false // by default if Code is in the background, intervals and timeouts get throttled
......@@ -197,17 +203,19 @@ export class VSCodeWindow {
this._win = new BrowserWindow(options);
this._id = this._win.id;
if (showDirectly && this.currentWindowMode === WindowMode.Maximized) {
if (isFullscreenOrMaximized) {
this.win.maximize();
if (this.currentWindowMode === WindowMode.Fullscreen) {
this.win.setFullScreen(true);
}
if (!this.win.isVisible()) {
this.win.show(); // to reduce flicker from the default window size to maximize, we only show after maximize
}
}
if (showDirectly) {
this._lastFocusTime = Date.now(); // since we show directly, we need to set the last focus time too
}
this._lastFocusTime = Date.now(); // since we show directly, we need to set the last focus time too
if (this.storageService.getItem<boolean>(VSCodeWindow.menuBarHiddenKey, false)) {
this.setMenuBarVisibility(false); // respect configured menu bar visibility
......@@ -422,7 +430,9 @@ export class VSCodeWindow {
public serializeWindowState(): IWindowState {
if (this.win.isFullScreen()) {
return defaultWindowState(); // ignore state when in fullscreen mode and return defaults
return {
mode: WindowMode.Fullscreen
};
}
let state: IWindowState = Object.create(null);
......@@ -480,6 +490,14 @@ export class VSCodeWindow {
return null;
}
if (state.mode === WindowMode.Fullscreen) {
if (this.options.allowFullscreen) {
return state;
}
return null;
}
if ([state.x, state.y, state.width, state.height].some(n => typeof n !== 'number')) {
return null;
}
......
......@@ -899,7 +899,8 @@ export class WindowsManager implements IWindowsService {
if (!vscodeWindow) {
vscodeWindow = this.instantiationService.createInstance(VSCodeWindow, {
state: this.getNewWindowState(configuration),
extensionDevelopmentPath: configuration.extensionDevelopmentPath
extensionDevelopmentPath: configuration.extensionDevelopmentPath,
allowFullscreen: this.lifecycleService.wasUpdated || this.settingsService.getValue('window.restoreFullscreen', false)
});
WindowsManager.WINDOWS.push(vscodeWindow);
......
......@@ -56,6 +56,11 @@ configurationRegistry.registerConfiguration({
'default': 'one',
'description': nls.localize('reopenFolders', "Controls how folders are being reopened after a restart. Select 'none' to never reopen a folder, 'one' to reopen the last folder you worked on or 'all' to reopen all folders of your last session.")
},
'window.restoreFullscreen': {
'type': 'boolean',
'default': false,
'description': nls.localize('restoreFullscreen', "Controls if a window should restore to full screen mode if it was exited in full screen mode.")
},
'window.zoomLevel': {
'type': 'number',
'default': 0,
......
......@@ -25,6 +25,7 @@ export interface IWindowConfiguration {
window: {
openFilesInNewWindow: boolean;
reopenFolders: string;
restoreFullscreen: boolean;
zoomLevel: number;
};
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册