Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/platform/windows/electron-main/window.ts')
-rw-r--r--src/vs/platform/windows/electron-main/window.ts32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/vs/platform/windows/electron-main/window.ts b/src/vs/platform/windows/electron-main/window.ts
index 216d743026f..85fc9e0c27e 100644
--- a/src/vs/platform/windows/electron-main/window.ts
+++ b/src/vs/platform/windows/electron-main/window.ts
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
-import { app, BrowserWindow, BrowserWindowConstructorOptions, Display, Event, nativeImage, NativeImage, Rectangle, screen, SegmentedControlSegment, systemPreferences, TouchBar, TouchBarSegmentedControl } from 'electron';
+import { app, BrowserWindow, BrowserWindowConstructorOptions, Display, Event, nativeImage, NativeImage, Point, Rectangle, screen, SegmentedControlSegment, systemPreferences, TouchBar, TouchBarSegmentedControl } from 'electron';
import { RunOnceScheduler } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { toErrorMessage } from 'vs/base/common/errorMessage';
@@ -90,6 +90,9 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private readonly _onDidSignalReady = this._register(new Emitter<void>());
readonly onDidSignalReady = this._onDidSignalReady.event;
+ private readonly _onDidTriggerSystemContextMenu = this._register(new Emitter<{ x: number; y: number }>());
+ readonly onDidTriggerSystemContextMenu = this._onDidTriggerSystemContextMenu.event;
+
private readonly _onDidClose = this._register(new Emitter<void>());
readonly onDidClose = this._onDidClose.event;
@@ -138,6 +141,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private documentEdited: boolean | undefined;
private customTrafficLightPosition: boolean | undefined;
+ private defaultTrafficLightPosition: Point | undefined;
private readonly whenReadyCallbacks: { (window: ICodeWindow): void }[] = [];
@@ -286,6 +290,22 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this._win.setSheetOffset(22); // offset dialogs by the height of the custom title bar if we have any
}
+ // Windows Custom System Context Menu
+ // See https://github.com/electron/electron/issues/24893
+ if (isWindows && useCustomTitleStyle) {
+ const WM_INITMENU = 0x0116;
+ this._win.hookWindowMessage(WM_INITMENU, () => {
+ const [x, y] = this._win.getPosition();
+ const cursorPos = screen.getCursorScreenPoint();
+
+ this._win.setEnabled(false);
+ this._win.setEnabled(true);
+
+ this._onDidTriggerSystemContextMenu.fire({ x: cursorPos.x - x, y: cursorPos.y - y });
+ return 0; // skip native menu
+ });
+ }
+
// TODO@electron (Electron 4 regression): when running on multiple displays where the target display
// to open the window has a larger resolution than the primary display, the window will not size
// correctly unless we set the bounds again (https://github.com/microsoft/vscode/issues/74872)
@@ -880,6 +900,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// Delete some properties we do not want during reload
delete configuration.filesToOpenOrCreate;
delete configuration.filesToDiff;
+ delete configuration.filesToMerge;
delete configuration.filesToWait;
// Some configuration things get inherited if the window is being reloaded and we are
@@ -1305,9 +1326,14 @@ export class CodeWindow extends Disposable implements ICodeWindow {
const useCustomTrafficLightPosition = this.configurationService.getValue<boolean>(commandCenterSettingKey);
if (useCustomTrafficLightPosition) {
- this._win.setTrafficLightPosition({ x: 7, y: 9 });
+ if (!this.defaultTrafficLightPosition) {
+ this.defaultTrafficLightPosition = this._win.getTrafficLightPosition(); // remember default to restore later
+ }
+ this._win.setTrafficLightPosition({ x: 7, y: 10 });
} else {
- this._win.setTrafficLightPosition({ x: 7, y: 6 });
+ if (this.defaultTrafficLightPosition) {
+ this._win.setTrafficLightPosition(this.defaultTrafficLightPosition);
+ }
}
this.customTrafficLightPosition = useCustomTrafficLightPosition;