mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 09:35:40 -05:00
* Merge from vscode a348d103d1256a06a2c9b3f9b406298a9fef6898 * Fixes and cleanup * Distro * Fix hygiene yarn * delete no yarn lock changes file * Fix hygiene * Fix layer check * Fix CI * Skip lib checks * Remove tests deleted in vs code * Fix tests * Distro * Fix tests and add removed extension point * Skip failing notebook tests for now * Disable broken tests and cleanup build folder * Update yarn.lock and fix smoke tests * Bump sqlite * fix contributed actions and file spacing * Fix user data path * Update yarn.locks Co-authored-by: ADS Merger <karlb@microsoft.com>
209 lines
6.0 KiB
TypeScript
209 lines
6.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { IWindowOpenable, IOpenEmptyWindowOptions, INativeWindowConfiguration } from 'vs/platform/windows/common/windows';
|
|
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
|
import { Event } from 'vs/base/common/event';
|
|
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
|
import { IProcessEnvironment } from 'vs/base/common/platform';
|
|
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
|
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
|
|
import { URI } from 'vs/base/common/uri';
|
|
import { Rectangle, BrowserWindow, WebContents } from 'electron';
|
|
import { IDisposable } from 'vs/base/common/lifecycle';
|
|
import { CancellationToken } from 'vs/base/common/cancellation';
|
|
|
|
export const enum OpenContext {
|
|
|
|
// opening when running from the command line
|
|
CLI,
|
|
|
|
// macOS only: opening from the dock (also when opening files to a running instance from desktop)
|
|
DOCK,
|
|
|
|
// opening from the main application window
|
|
MENU,
|
|
|
|
// opening from a file or folder dialog
|
|
DIALOG,
|
|
|
|
// opening from the OS's UI
|
|
DESKTOP,
|
|
|
|
// opening through the API
|
|
API
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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 backupPath?: string;
|
|
|
|
readonly remoteAuthority?: string;
|
|
|
|
readonly isExtensionDevelopmentHost: boolean;
|
|
readonly isExtensionTestHost: boolean;
|
|
|
|
readonly lastFocusTime: number;
|
|
|
|
readonly isReady: boolean;
|
|
ready(): Promise<ICodeWindow>;
|
|
setReady(): void;
|
|
|
|
readonly hasHiddenTitleBarStyle: boolean;
|
|
|
|
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 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
|
|
}
|
|
|
|
export const IWindowsMainService = createDecorator<IWindowsMainService>('windowsMainService');
|
|
|
|
export interface IWindowsCountChangedEvent {
|
|
readonly oldCount: number;
|
|
readonly newCount: number;
|
|
}
|
|
|
|
export interface IWindowsMainService {
|
|
|
|
readonly _serviceBrand: undefined;
|
|
|
|
readonly onDidChangeWindowsCount: Event<IWindowsCountChangedEvent>;
|
|
|
|
readonly onDidOpenWindow: Event<ICodeWindow>;
|
|
readonly onDidSignalReadyWindow: Event<ICodeWindow>;
|
|
readonly onDidDestroyWindow: Event<ICodeWindow>;
|
|
|
|
open(openConfig: IOpenConfiguration): ICodeWindow[];
|
|
openEmptyWindow(openConfig: IOpenEmptyConfiguration, options?: IOpenEmptyWindowOptions): ICodeWindow[];
|
|
openExtensionDevelopmentHostWindow(extensionDevelopmentPath: string[], openConfig: IOpenConfiguration): ICodeWindow[];
|
|
|
|
sendToFocused(channel: string, ...args: any[]): void;
|
|
sendToAll(channel: string, payload?: any, windowIdsToIgnore?: number[]): void;
|
|
|
|
getWindows(): ICodeWindow[];
|
|
getWindowCount(): number;
|
|
|
|
getFocusedWindow(): ICodeWindow | undefined;
|
|
getLastActiveWindow(): ICodeWindow | undefined;
|
|
|
|
getWindowById(windowId: number): ICodeWindow | undefined;
|
|
getWindowByWebContents(webContents: WebContents): ICodeWindow | undefined;
|
|
}
|
|
|
|
export interface IBaseOpenConfiguration {
|
|
readonly context: OpenContext;
|
|
readonly contextWindowId?: number;
|
|
}
|
|
|
|
export interface IOpenConfiguration extends IBaseOpenConfiguration {
|
|
readonly cli: NativeParsedArgs;
|
|
readonly userEnv?: IProcessEnvironment;
|
|
readonly urisToOpen?: IWindowOpenable[];
|
|
readonly waitMarkerFileURI?: URI;
|
|
readonly preferNewWindow?: boolean;
|
|
readonly forceNewWindow?: boolean;
|
|
readonly forceNewTabbedWindow?: boolean;
|
|
readonly forceReuseWindow?: boolean;
|
|
readonly forceEmpty?: boolean;
|
|
readonly diffMode?: boolean;
|
|
addMode?: boolean;
|
|
readonly gotoLineMode?: boolean;
|
|
readonly initialStartup?: boolean;
|
|
readonly noRecentEntry?: boolean;
|
|
/**
|
|
* The remote authority to use when windows are opened with either
|
|
* - no workspace (empty window)
|
|
* - a workspace that is neither `file://` nor `vscode-remote://`
|
|
*/
|
|
readonly remoteAuthority?: string;
|
|
}
|
|
|
|
export interface IOpenEmptyConfiguration extends IBaseOpenConfiguration { }
|