Skip to content

Commit dfb96d1

Browse files
authored
wco - hardcode devtools location on Linux (microsoft#227084)
1 parent 79c48ea commit dfb96d1

File tree

4 files changed

+22
-26
lines changed

4 files changed

+22
-26
lines changed

src/vs/base/parts/sandbox/common/electronTypes.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -217,24 +217,6 @@ export interface FileFilter {
217217
name: string;
218218
}
219219

220-
export interface OpenDevToolsOptions {
221-
/**
222-
* Opens the devtools with specified dock state, can be `left`, `right`, `bottom`,
223-
* `undocked`, `detach`. Defaults to last used dock state. In `undocked` mode it's
224-
* possible to dock back. In `detach` mode it's not.
225-
*/
226-
mode: ('left' | 'right' | 'bottom' | 'undocked' | 'detach');
227-
/**
228-
* Whether to bring the opened devtools window to the foreground. The default is
229-
* `true`.
230-
*/
231-
activate?: boolean;
232-
/**
233-
* A title for the DevTools window (only in `undocked` or `detach` mode).
234-
*/
235-
title?: string;
236-
}
237-
238220
interface InputEvent {
239221

240222
// Docs: https://electronjs.org/docs/api/structures/input-event

src/vs/platform/native/common/native.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { VSBuffer } from 'vs/base/common/buffer';
77
import { Event } from 'vs/base/common/event';
88
import { URI } from 'vs/base/common/uri';
9-
import { MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'vs/base/parts/sandbox/common/electronTypes';
9+
import { MessageBoxOptions, MessageBoxReturnValue, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'vs/base/parts/sandbox/common/electronTypes';
1010
import { ISerializableCommandAction } from 'vs/platform/action/common/action';
1111
import { INativeOpenDialogOptions } from 'vs/platform/dialogs/common/dialogs';
1212
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -178,7 +178,7 @@ export interface ICommonNativeHostService {
178178
exit(code: number): Promise<void>;
179179

180180
// Development
181-
openDevTools(options?: Partial<OpenDevToolsOptions> & INativeHostOptions): Promise<void>;
181+
openDevTools(options?: INativeHostOptions): Promise<void>;
182182
toggleDevTools(options?: INativeHostOptions): Promise<void>;
183183

184184
// Perf Introspection

src/vs/platform/native/electron-main/nativeHostMainService.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as fs from 'fs';
77
import { exec } from 'child_process';
8-
import { app, BrowserWindow, clipboard, Display, Menu, MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, OpenDialogOptions, OpenDialogReturnValue, powerMonitor, SaveDialogOptions, SaveDialogReturnValue, screen, shell, webContents } from 'electron';
8+
import { app, BrowserWindow, clipboard, Display, Menu, MessageBoxOptions, MessageBoxReturnValue, OpenDialogOptions, OpenDialogReturnValue, powerMonitor, SaveDialogOptions, SaveDialogReturnValue, screen, shell, webContents } from 'electron';
99
import { arch, cpus, freemem, loadavg, platform, release, totalmem, type } from 'os';
1010
import { promisify } from 'util';
1111
import { memoize } from 'vs/base/common/decorators';
@@ -33,7 +33,7 @@ import { IProductService } from 'vs/platform/product/common/productService';
3333
import { IPartsSplash } from 'vs/platform/theme/common/themeService';
3434
import { IThemeMainService } from 'vs/platform/theme/electron-main/themeMainService';
3535
import { ICodeWindow } from 'vs/platform/window/electron-main/window';
36-
import { IColorScheme, IOpenedAuxiliaryWindow, IOpenedMainWindow, IOpenEmptyWindowOptions, IOpenWindowOptions, IPoint, IRectangle, IWindowOpenable } from 'vs/platform/window/common/window';
36+
import { IColorScheme, IOpenedAuxiliaryWindow, IOpenedMainWindow, IOpenEmptyWindowOptions, IOpenWindowOptions, IPoint, IRectangle, IWindowOpenable, useWindowControlsOverlay } from 'vs/platform/window/common/window';
3737
import { IWindowsMainService, OpenContext } from 'vs/platform/windows/electron-main/windows';
3838
import { isWorkspaceIdentifier, toWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
3939
import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
@@ -855,14 +855,28 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
855855

856856
//#region Development
857857

858-
async openDevTools(windowId: number | undefined, options?: Partial<OpenDevToolsOptions> & INativeHostOptions): Promise<void> {
858+
async openDevTools(windowId: number | undefined, options?: INativeHostOptions): Promise<void> {
859859
const window = this.windowById(options?.targetWindowId, windowId);
860-
window?.win?.webContents.openDevTools(options?.mode ? { mode: options.mode, activate: options.activate } : undefined);
860+
861+
let mode: 'bottom' | undefined = undefined;
862+
if (isLinux && useWindowControlsOverlay(this.configurationService)) {
863+
mode = 'bottom'; // TODO@bpasero WCO and devtools collide with default option 'right'
864+
}
865+
window?.win?.webContents.openDevTools(mode ? { mode } : undefined);
861866
}
862867

863868
async toggleDevTools(windowId: number | undefined, options?: INativeHostOptions): Promise<void> {
864869
const window = this.windowById(options?.targetWindowId, windowId);
865-
window?.win?.webContents.toggleDevTools();
870+
const webContents = window?.win?.webContents;
871+
if (!webContents) {
872+
return;
873+
}
874+
875+
if (isLinux && useWindowControlsOverlay(this.configurationService) && !webContents.isDevToolsOpened()) {
876+
webContents.openDevTools({ mode: 'bottom' }); // TODO@bpasero WCO and devtools collide with default option 'right'
877+
} else {
878+
webContents.toggleDevTools();
879+
}
866880
}
867881

868882
//#endregion

src/vs/workbench/test/electron-sandbox/workbenchTestServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class TestNativeHostService implements INativeHostService {
143143
async closeWindow(): Promise<void> { }
144144
async quit(): Promise<void> { }
145145
async exit(code: number): Promise<void> { }
146-
async openDevTools(options?: Partial<Electron.OpenDevToolsOptions> & INativeHostOptions | undefined): Promise<void> { }
146+
async openDevTools(): Promise<void> { }
147147
async toggleDevTools(): Promise<void> { }
148148
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
149149
async lookupAuthorization(authInfo: AuthInfo): Promise<Credentials | undefined> { return undefined; }

0 commit comments

Comments
 (0)