mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-24 09:21:35 +01:00
How to configure a window (also for reload case)? (fixes #27192)
This commit is contained in:
committed by
Dirk Baeumer
parent
27625c21a2
commit
a8fb36fc28
@@ -9,7 +9,7 @@ import * as nls from 'vs/nls';
|
||||
import { isMacintosh, isLinux, isWindows, language } from 'vs/base/common/platform';
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { ipcMain as ipc, app, shell, dialog, Menu, MenuItem } from 'electron';
|
||||
import { ipcMain as ipc, app, shell, dialog, Menu, MenuItem, BrowserWindow } from 'electron';
|
||||
import { OpenContext } from 'vs/code/common/windows';
|
||||
import { IWindowsMainService } from 'vs/code/electron-main/windows';
|
||||
import { VSCodeWindow } from 'vs/code/electron-main/window';
|
||||
@@ -908,7 +908,7 @@ export class VSCodeMenu {
|
||||
label: this.mnemonicLabel(nls.localize({ key: 'miAccessibilityOptions', comment: ['&& denotes a mnemonic'] }, "Accessibility &&Options")),
|
||||
accelerator: null,
|
||||
click: () => {
|
||||
this.windowsService.openAccessibilityOptions();
|
||||
this.openAccessibilityOptions();
|
||||
}
|
||||
}, false));
|
||||
|
||||
@@ -974,6 +974,22 @@ export class VSCodeMenu {
|
||||
}
|
||||
}
|
||||
|
||||
private openAccessibilityOptions(): void {
|
||||
let win = new BrowserWindow({
|
||||
alwaysOnTop: true,
|
||||
skipTaskbar: true,
|
||||
resizable: false,
|
||||
width: 450,
|
||||
height: 300,
|
||||
show: true,
|
||||
title: nls.localize('accessibilityOptionsWindowTitle', "Accessibility Options")
|
||||
});
|
||||
|
||||
win.setMenuBarVisibility(false);
|
||||
|
||||
win.loadURL('chrome://accessibility');
|
||||
}
|
||||
|
||||
private getUpdateMenuItems(): Electron.MenuItem[] {
|
||||
switch (this.updateService.state) {
|
||||
case UpdateState.Uninitialized:
|
||||
|
||||
@@ -22,7 +22,7 @@ import product from 'vs/platform/node/product';
|
||||
import { getCommonHTTPHeaders } from 'vs/platform/environment/node/http';
|
||||
import { IWindowSettings, MenuBarVisibility } from 'vs/platform/windows/common/windows';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
|
||||
import { KeyboardLayoutMonitor } from "vs/code/node/keyboard";
|
||||
|
||||
export interface IWindowState {
|
||||
width?: number;
|
||||
@@ -82,10 +82,7 @@ export interface IWindowConfiguration extends ParsedArgs {
|
||||
* The physical keyboard is of ISO type (on OSX).
|
||||
*/
|
||||
isISOKeyboard?: boolean;
|
||||
/**
|
||||
* Accessibility support is enabled.
|
||||
*/
|
||||
accessibilitySupportEnabled?: boolean;
|
||||
|
||||
zoomLevel?: number;
|
||||
fullscreen?: boolean;
|
||||
highContrast?: boolean;
|
||||
@@ -558,6 +555,9 @@ export class VSCodeWindow {
|
||||
windowConfiguration.highContrast = platform.isWindows && systemPreferences.isInvertedColorScheme() && (!windowConfig || windowConfig.autoDetectHighContrast);
|
||||
windowConfiguration.accessibilitySupport = app.isAccessibilitySupportEnabled();
|
||||
|
||||
// Set Keyboard Config
|
||||
windowConfiguration.isISOKeyboard = KeyboardLayoutMonitor.INSTANCE.isISOKeyboard();
|
||||
|
||||
// Theme
|
||||
windowConfiguration.baseTheme = this.getBaseTheme();
|
||||
windowConfiguration.backgroundColor = this.getBackgroundColor();
|
||||
|
||||
@@ -31,8 +31,7 @@ import product from 'vs/platform/node/product';
|
||||
import { OpenContext } from 'vs/code/common/windows';
|
||||
import { ITelemetryService, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { isParent, isEqual, isEqualOrParent } from 'vs/platform/files/common/files';
|
||||
import * as nativeKeymap from 'native-keymap';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { KeyboardLayoutMonitor } from "vs/code/node/keyboard";
|
||||
|
||||
enum WindowError {
|
||||
UNRESPONSIVE,
|
||||
@@ -107,7 +106,6 @@ export interface IWindowsMainService {
|
||||
openFileFolderPicker(forceNewWindow?: boolean, data?: ITelemetryData): void;
|
||||
openFilePicker(forceNewWindow?: boolean, path?: string, window?: VSCodeWindow, data?: ITelemetryData): void;
|
||||
openFolderPicker(forceNewWindow?: boolean, window?: VSCodeWindow, data?: ITelemetryData): void;
|
||||
openAccessibilityOptions(): void;
|
||||
focusLastActive(cli: ParsedArgs, context: OpenContext): VSCodeWindow;
|
||||
getLastActiveWindow(): VSCodeWindow;
|
||||
findWindow(workspacePath: string, filePath?: string, extensionDevelopmentPath?: string): VSCodeWindow;
|
||||
@@ -343,6 +341,7 @@ export class WindowsManager implements IWindowsMainService {
|
||||
}
|
||||
|
||||
private onBroadcast(event: string, payload: any): void {
|
||||
|
||||
// Theme changes
|
||||
if (event === 'vscode:changeColorTheme' && typeof payload === 'string') {
|
||||
|
||||
@@ -737,8 +736,6 @@ export class WindowsManager implements IWindowsMainService {
|
||||
configuration.filesToCreate = filesToCreate;
|
||||
configuration.filesToDiff = filesToDiff;
|
||||
configuration.nodeCachedDataDir = this.environmentService.nodeCachedDataDir;
|
||||
configuration.isISOKeyboard = KeyboardLayoutMonitor.INSTANCE.isISOKeyboard();
|
||||
configuration.accessibilitySupportEnabled = app.isAccessibilitySupportEnabled();
|
||||
|
||||
return configuration;
|
||||
}
|
||||
@@ -1028,22 +1025,6 @@ export class WindowsManager implements IWindowsMainService {
|
||||
this.doPickAndOpen({ pickFolders: true, forceNewWindow, window }, 'openFolder', data);
|
||||
}
|
||||
|
||||
public openAccessibilityOptions(): void {
|
||||
let win = new BrowserWindow({
|
||||
alwaysOnTop: true,
|
||||
skipTaskbar: true,
|
||||
resizable: false,
|
||||
width: 450,
|
||||
height: 300,
|
||||
show: true,
|
||||
title: nls.localize('accessibilityOptionsWindowTitle', "Accessibility Options")
|
||||
});
|
||||
|
||||
win.setMenuBarVisibility(false);
|
||||
|
||||
win.loadURL('chrome://accessibility');
|
||||
}
|
||||
|
||||
private doPickAndOpen(options: INativeOpenDialogOptions, eventName: string, data?: ITelemetryData): void {
|
||||
this.getFileOrFolderPaths(options, (paths: string[]) => {
|
||||
const nOfPaths = paths ? paths.length : 0;
|
||||
@@ -1338,63 +1319,4 @@ export class WindowsManager implements IWindowsMainService {
|
||||
}, 10 /* delay to unwind callback stack (IPC) */);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KeyboardLayoutMonitor {
|
||||
|
||||
public static INSTANCE = new KeyboardLayoutMonitor();
|
||||
|
||||
private _emitter: Emitter<boolean>;
|
||||
private _registered: boolean;
|
||||
private _isISOKeyboard: boolean;
|
||||
|
||||
private constructor() {
|
||||
this._emitter = new Emitter<boolean>();
|
||||
this._registered = false;
|
||||
this._isISOKeyboard = this._readIsISOKeyboard();
|
||||
}
|
||||
|
||||
public onDidChangeKeyboardLayout(callback: (isISOKeyboard: boolean) => void): IDisposable {
|
||||
if (!this._registered) {
|
||||
this._registered = true;
|
||||
|
||||
nativeKeymap.onDidChangeKeyboardLayout(() => {
|
||||
this._emitter.fire(this._isISOKeyboard);
|
||||
});
|
||||
|
||||
if (platform.isMacintosh) {
|
||||
// See https://github.com/Microsoft/vscode/issues/24153
|
||||
// On OSX, on ISO keyboards, Chromium swaps the scan codes
|
||||
// of IntlBackslash and Backquote.
|
||||
//
|
||||
// The C++ methods can give the current keyboard type (ISO or not)
|
||||
// only after a NSEvent was handled.
|
||||
//
|
||||
// We therefore poll.
|
||||
setInterval(() => {
|
||||
let newValue = this._readIsISOKeyboard();
|
||||
if (this._isISOKeyboard === newValue) {
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
|
||||
this._isISOKeyboard = newValue;
|
||||
this._emitter.fire(this._isISOKeyboard);
|
||||
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
return this._emitter.event(callback);
|
||||
}
|
||||
|
||||
private _readIsISOKeyboard(): boolean {
|
||||
if (platform.isMacintosh) {
|
||||
return nativeKeymap.isISOKeyboard();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public isISOKeyboard(): boolean {
|
||||
return this._isISOKeyboard;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import * as nativeKeymap from 'native-keymap';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { isMacintosh } from "vs/base/common/platform";
|
||||
import { Emitter } from "vs/base/common/event";
|
||||
|
||||
export class KeyboardLayoutMonitor {
|
||||
|
||||
public static readonly INSTANCE = new KeyboardLayoutMonitor();
|
||||
|
||||
private _emitter: Emitter<boolean>;
|
||||
private _registered: boolean;
|
||||
private _isISOKeyboard: boolean;
|
||||
|
||||
private constructor() {
|
||||
this._emitter = new Emitter<boolean>();
|
||||
this._registered = false;
|
||||
this._isISOKeyboard = this._readIsISOKeyboard();
|
||||
}
|
||||
|
||||
public onDidChangeKeyboardLayout(callback: (isISOKeyboard: boolean) => void): IDisposable {
|
||||
if (!this._registered) {
|
||||
this._registered = true;
|
||||
|
||||
nativeKeymap.onDidChangeKeyboardLayout(() => {
|
||||
this._emitter.fire(this._isISOKeyboard);
|
||||
});
|
||||
|
||||
if (isMacintosh) {
|
||||
// See https://github.com/Microsoft/vscode/issues/24153
|
||||
// On OSX, on ISO keyboards, Chromium swaps the scan codes
|
||||
// of IntlBackslash and Backquote.
|
||||
//
|
||||
// The C++ methods can give the current keyboard type (ISO or not)
|
||||
// only after a NSEvent was handled.
|
||||
//
|
||||
// We therefore poll.
|
||||
setInterval(() => {
|
||||
let newValue = this._readIsISOKeyboard();
|
||||
if (this._isISOKeyboard === newValue) {
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
|
||||
this._isISOKeyboard = newValue;
|
||||
this._emitter.fire(this._isISOKeyboard);
|
||||
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
return this._emitter.event(callback);
|
||||
}
|
||||
|
||||
private _readIsISOKeyboard(): boolean {
|
||||
if (isMacintosh) {
|
||||
return nativeKeymap.isISOKeyboard();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public isISOKeyboard(): boolean {
|
||||
return this._isISOKeyboard;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user