Skip to content

Commit

Permalink
Keep process explorer window on top, fixes #120391
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Macfarlane committed May 7, 2021
1 parent 403723c commit a92c366
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/vs/platform/issue/electron-main/issueMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import { DisposableStore } from 'vs/base/common/lifecycle';

export const IIssueMainService = createDecorator<IIssueMainService>('issueMainService');

interface IBrowserWindowOptions {
backgroundColor: string | undefined;
title: string;
zoomLevel: number;
alwaysOnTop: boolean;
}

export interface IIssueMainService extends ICommonIssueService { }

export class IssueMainService implements ICommonIssueService {
Expand Down Expand Up @@ -189,7 +196,12 @@ export class IssueMainService implements ICommonIssueService {
const issueReporterWindowConfigUrl = issueReporterDisposables.add(this.protocolMainService.createIPCObjectUrl<IssueReporterWindowConfiguration>());
const position = this.getWindowPosition(this.issueReporterParentWindow, 700, 800);

this.issueReporterWindow = this.createBrowserWindow(position, issueReporterWindowConfigUrl, data.styles.backgroundColor, localize('issueReporter', "Issue Reporter"), data.zoomLevel);
this.issueReporterWindow = this.createBrowserWindow(position, issueReporterWindowConfigUrl, {
backgroundColor: data.styles.backgroundColor,
title: localize('issueReporter', "Issue Reporter"),
zoomLevel: data.zoomLevel,
alwaysOnTop: false
});

// Store into config object URL
issueReporterWindowConfigUrl.update({
Expand Down Expand Up @@ -239,7 +251,12 @@ export class IssueMainService implements ICommonIssueService {
const processExplorerWindowConfigUrl = processExplorerDisposables.add(this.protocolMainService.createIPCObjectUrl<ProcessExplorerWindowConfiguration>());
const position = this.getWindowPosition(this.processExplorerParentWindow, 800, 500);

this.processExplorerWindow = this.createBrowserWindow(position, processExplorerWindowConfigUrl, data.styles.backgroundColor, localize('processExplorer', "Process Explorer"), data.zoomLevel);
this.processExplorerWindow = this.createBrowserWindow(position, processExplorerWindowConfigUrl, {
backgroundColor: data.styles.backgroundColor,
title: localize('processExplorer', "Process Explorer"),
zoomLevel: data.zoomLevel,
alwaysOnTop: true
});

// Store into config object URL
processExplorerWindowConfigUrl.update({
Expand Down Expand Up @@ -273,7 +290,7 @@ export class IssueMainService implements ICommonIssueService {
this.processExplorerWindow?.focus();
}

private createBrowserWindow<T>(position: IWindowState, ipcObjectUrl: IIPCObjectUrl<T>, backgroundColor: string | undefined, title: string, zoomLevel: number): BrowserWindow {
private createBrowserWindow<T>(position: IWindowState, ipcObjectUrl: IIPCObjectUrl<T>, options: IBrowserWindowOptions): BrowserWindow {
const window = new BrowserWindow({
fullscreen: false,
skipTaskbar: true,
Expand All @@ -284,8 +301,8 @@ export class IssueMainService implements ICommonIssueService {
minHeight: 200,
x: position.x,
y: position.y,
title,
backgroundColor: backgroundColor || IssueMainService.DEFAULT_BACKGROUND_COLOR,
title: options.title,
backgroundColor: options.backgroundColor || IssueMainService.DEFAULT_BACKGROUND_COLOR,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
additionalArguments: [`--vscode-window-config=${ipcObjectUrl.resource.toString()}`, '--context-isolation' /* TODO@bpasero: Use process.contextIsolateed when 13-x-y is adopted (https://github.com/electron/electron/pull/28030) */],
Expand All @@ -294,10 +311,11 @@ export class IssueMainService implements ICommonIssueService {
enableRemoteModule: false,
spellcheck: false,
nativeWindowOpen: true,
zoomFactor: zoomLevelToZoomFactor(zoomLevel),
zoomFactor: zoomLevelToZoomFactor(options.zoomLevel),
sandbox: true,
contextIsolation: true
}
contextIsolation: true,
},
alwaysOnTop: options.alwaysOnTop
});

window.setMenuBarVisibility(false);
Expand Down

0 comments on commit a92c366

Please sign in to comment.