1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { BrowserWindow, Rectangle } from 'electron';
import { CancellationToken } from 'vs/base/common/cancellation';
import { Event } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';
import { ISerializableCommandAction } from 'vs/platform/action/common/action';
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
import { INativeWindowConfiguration } from 'vs/platform/window/common/window';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
export interface ICodeWindow extends IDisposable {
readonly onWillLoad: Event<ILoadEvent>;
readonly onDidSignalReady: Event<void>;
readonly onDidClose: Event<void>;
readonly onDidDestroy: Event<void>;
readonly whenClosedOrLoaded: Promise<void>;
readonly id: number;
readonly win: BrowserWindow | null; /* `null` after being disposed */
readonly config: INativeWindowConfiguration | undefined;
readonly openedWorkspace?: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier;
readonly profile?: IUserDataProfile;
readonly backupPath?: string;
readonly remoteAuthority?: string;
readonly isExtensionDevelopmentHost: boolean;
readonly isExtensionTestHost: boolean;
readonly lastFocusTime: number;
readonly isReady: boolean;
ready(): Promise<ICodeWindow>;
setReady(): void;
addTabbedWindow(window: ICodeWindow): void;
load(config: INativeWindowConfiguration, options?: { isReload?: boolean }): void;
reload(cli?: NativeParsedArgs): void;
focus(options?: { force: boolean }): void;
close(): void;
getBounds(): Rectangle;
send(channel: string, ...args: any[]): void;
sendWhenReady(channel: string, token: CancellationToken, ...args: any[]): void;
readonly isFullScreen: boolean;
toggleFullScreen(): void;
isMinimized(): boolean;
setRepresentedFilename(name: string): void;
getRepresentedFilename(): string | undefined;
setDocumentEdited(edited: boolean): void;
isDocumentEdited(): boolean;
handleTitleDoubleClick(): void;
updateTouchBar(items: ISerializableCommandAction[][]): void;
serializeWindowState(): IWindowState;
}
export const enum LoadReason {
/**
* The window is loaded for the first time.
*/
INITIAL = 1,
/**
* The window is loaded into a different workspace context.
*/
LOAD,
/**
* The window is reloaded.
*/
RELOAD
}
export const enum UnloadReason {
/**
* The window is closed.
*/
CLOSE = 1,
/**
* All windows unload because the application quits.
*/
QUIT,
/**
* The window is reloaded.
*/
RELOAD,
/**
* The window is loaded into a different workspace context.
*/
LOAD
}
export interface IWindowState {
width?: number;
height?: number;
x?: number;
y?: number;
mode?: WindowMode;
display?: number;
}
export const defaultWindowState = function (mode = WindowMode.Normal): IWindowState {
return {
width: 1024,
height: 768,
mode
};
};
export const enum WindowMode {
Maximized,
Normal,
Minimized, // not used anymore, but also cannot remove due to existing stored UI state (needs migration)
Fullscreen
}
export interface ILoadEvent {
workspace: IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | undefined;
reason: LoadReason;
}
export const enum WindowError {
/**
* Maps to the `unresponsive` event on a `BrowserWindow`.
*/
UNRESPONSIVE = 1,
/**
* Maps to the `render-proces-gone` event on a `WebContents`.
*/
CRASHED = 2,
/**
* Maps to the `did-fail-load` event on a `WebContents`.
*/
LOAD = 3
}
|