Skip to content

Commit

Permalink
Revert "wco - hardcode devtools location on Linux (#227084)"
Browse files Browse the repository at this point in the history
This reverts commit dfb96d1.
  • Loading branch information
deepak1556 committed Sep 19, 2024
1 parent 0f90047 commit 95e2226
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
18 changes: 18 additions & 0 deletions src/vs/base/parts/sandbox/common/electronTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@ export interface FileFilter {
name: string;
}

export interface OpenDevToolsOptions {
/**
* Opens the devtools with specified dock state, can be `left`, `right`, `bottom`,
* `undocked`, `detach`. Defaults to last used dock state. In `undocked` mode it's
* possible to dock back. In `detach` mode it's not.
*/
mode: ('left' | 'right' | 'bottom' | 'undocked' | 'detach');
/**
* Whether to bring the opened devtools window to the foreground. The default is
* `true`.
*/
activate?: boolean;
/**
* A title for the DevTools window (only in `undocked` or `detach` mode).
*/
title?: string;
}

interface InputEvent {

// Docs: https://electronjs.org/docs/api/structures/input-event
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/native/common/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { VSBuffer } from '../../../base/common/buffer.js';
import { Event } from '../../../base/common/event.js';
import { URI } from '../../../base/common/uri.js';
import { MessageBoxOptions, MessageBoxReturnValue, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from '../../../base/parts/sandbox/common/electronTypes.js';
import { MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from '../../../base/parts/sandbox/common/electronTypes.js';
import { ISerializableCommandAction } from '../../action/common/action.js';
import { INativeOpenDialogOptions } from '../../dialogs/common/dialogs.js';
import { createDecorator } from '../../instantiation/common/instantiation.js';
Expand Down Expand Up @@ -178,7 +178,7 @@ export interface ICommonNativeHostService {
exit(code: number): Promise<void>;

// Development
openDevTools(options?: INativeHostOptions): Promise<void>;
openDevTools(options?: Partial<OpenDevToolsOptions> & INativeHostOptions): Promise<void>;
toggleDevTools(options?: INativeHostOptions): Promise<void>;

// Perf Introspection
Expand Down
24 changes: 5 additions & 19 deletions src/vs/platform/native/electron-main/nativeHostMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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

//#region Development

async openDevTools(windowId: number | undefined, options?: INativeHostOptions): Promise<void> {
async openDevTools(windowId: number | undefined, options?: Partial<OpenDevToolsOptions> & INativeHostOptions): Promise<void> {
const window = this.windowById(options?.targetWindowId, windowId);

let mode: 'bottom' | undefined = undefined;
if (isLinux && useWindowControlsOverlay(this.configurationService)) {
mode = 'bottom'; // TODO@bpasero WCO and devtools collide with default option 'right'
}
window?.win?.webContents.openDevTools(mode ? { mode } : undefined);
window?.win?.webContents.openDevTools(options?.mode ? { mode: options.mode, activate: options.activate } : undefined);
}

async toggleDevTools(windowId: number | undefined, options?: INativeHostOptions): Promise<void> {
const window = this.windowById(options?.targetWindowId, windowId);
const webContents = window?.win?.webContents;
if (!webContents) {
return;
}

if (isLinux && useWindowControlsOverlay(this.configurationService) && !webContents.isDevToolsOpened()) {
webContents.openDevTools({ mode: 'bottom' }); // TODO@bpasero WCO and devtools collide with default option 'right'
} else {
webContents.toggleDevTools();
}
window?.win?.webContents.toggleDevTools();
}

//#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class TestNativeHostService implements INativeHostService {
async closeWindow(): Promise<void> { }
async quit(): Promise<void> { }
async exit(code: number): Promise<void> { }
async openDevTools(): Promise<void> { }
async openDevTools(options?: Partial<Electron.OpenDevToolsOptions> & INativeHostOptions | undefined): Promise<void> { }
async toggleDevTools(): Promise<void> { }
async resolveProxy(url: string): Promise<string | undefined> { return undefined; }
async lookupAuthorization(authInfo: AuthInfo): Promise<Credentials | undefined> { return undefined; }
Expand Down

0 comments on commit 95e2226

Please sign in to comment.