Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from microsoft:main #358

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/vs/platform/native/common/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ export interface ICommonNativeHostService {
isFullScreen(options?: INativeHostOptions): Promise<boolean>;
toggleFullScreen(options?: INativeHostOptions): Promise<void>;

handleTitleDoubleClick(options?: INativeHostOptions): Promise<void>;

getCursorScreenPoint(): Promise<{ readonly point: IPoint; readonly display: IRectangle }>;

isMaximized(options?: INativeHostOptions): Promise<boolean>;
Expand Down
5 changes: 0 additions & 5 deletions src/vs/platform/native/electron-main/nativeHostMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
window?.toggleFullScreen();
}

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

async getCursorScreenPoint(windowId: number | undefined): Promise<{ readonly point: IPoint; readonly display: IRectangle }> {
const point = screen.getCursorScreenPoint();
const display = screen.getDisplayNearestPoint(point);
Expand Down
2 changes: 0 additions & 2 deletions src/vs/platform/window/electron-main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export interface IBaseWindow extends IDisposable {
setDocumentEdited(edited: boolean): void;
isDocumentEdited(): boolean;

handleTitleDoubleClick(): void;

readonly isFullScreen: boolean;
toggleFullScreen(): void;

Expand Down
35 changes: 0 additions & 35 deletions src/vs/platform/windows/electron-main/windowImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,41 +314,6 @@ export abstract class BaseWindow extends Disposable implements IBaseWindow {
win.focus();
}

handleTitleDoubleClick(): void {
const win = this.win;
if (!win) {
return;
}

// Respect system settings on mac with regards to title click on windows title
if (isMacintosh) {
const action = electron.systemPreferences.getUserDefault('AppleActionOnDoubleClick', 'string');
switch (action) {
case 'Minimize':
win.minimize();
break;
case 'None':
break;
case 'Maximize':
default:
if (win.isMaximized()) {
win.unmaximize();
} else {
win.maximize();
}
}
}

// Linux/Windows: just toggle maximize/minimized state
else {
if (win.isMaximized()) {
win.unmaximize();
} else {
win.maximize();
}
}
}

//#region Window Control Overlays

private static readonly windowControlHeightStateStorageKey = 'windowControlHeight';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ suite('WindowsFinder', () => {
getRepresentedFilename(): string | undefined { throw new Error('Method not implemented.'); }
setDocumentEdited(edited: boolean): void { throw new Error('Method not implemented.'); }
isDocumentEdited(): boolean { throw new Error('Method not implemented.'); }
handleTitleDoubleClick(): void { throw new Error('Method not implemented.'); }
updateTouchBar(items: UriDto<ICommandAction>[][]): void { throw new Error('Method not implemented.'); }
serializeWindowState(): IWindowState { throw new Error('Method not implemented'); }
updateWindowControls(options: { height?: number | undefined; backgroundColor?: string | undefined; foregroundColor?: string | undefined }): void { throw new Error('Method not implemented.'); }
Expand Down
26 changes: 12 additions & 14 deletions src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,22 +434,20 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
this.centerContent = append(this.rootContainer, $('.titlebar-center'));
this.rightContent = append(this.rootContainer, $('.titlebar-right'));

// App Icon (Native Windows/Linux and Web)
if (!isMacintosh && !isWeb && !hasNativeTitlebar(this.configurationService, this.titleBarStyle)) {
// App Icon (Windows, Linux) / Home Indicator (Web)
const homeIndicator = this.environmentService.options?.homeIndicator;
const supportsAppIcon = isWindows || isLinux || (isWeb && homeIndicator && !this.isAuxiliary);
if (supportsAppIcon && !hasNativeTitlebar(this.configurationService, this.titleBarStyle)) {
this.appIcon = prepend(this.leftContent, $('a.window-appicon'));

// Web-only home indicator and menu (not for auxiliary windows)
if (!this.isAuxiliary && isWeb) {
const homeIndicator = this.environmentService.options?.homeIndicator;
if (homeIndicator) {
const icon: ThemeIcon = getIconRegistry().getIcon(homeIndicator.icon) ? { id: homeIndicator.icon } : Codicon.code;

this.appIcon.setAttribute('href', homeIndicator.href);
this.appIcon.classList.add(...ThemeIcon.asClassNameArray(icon));
this.appIconBadge = document.createElement('div');
this.appIconBadge.classList.add('home-bar-icon-badge');
this.appIcon.appendChild(this.appIconBadge);
}
// Web: home indicator
if (isWeb && homeIndicator) {
const icon: ThemeIcon = getIconRegistry().getIcon(homeIndicator.icon) ? { id: homeIndicator.icon } : Codicon.code;
this.appIcon.setAttribute('href', homeIndicator.href);
this.appIcon.classList.add(...ThemeIcon.asClassNameArray(icon));
this.appIconBadge = document.createElement('div');
this.appIconBadge.classList.add('home-bar-icon-badge');
this.appIcon.appendChild(this.appIconBadge);
}
}

Expand Down
20 changes: 2 additions & 18 deletions src/vs/workbench/electron-sandbox/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { localize } from '../../nls.js';
import { URI } from '../../base/common/uri.js';
import { onUnexpectedError } from '../../base/common/errors.js';
import { equals } from '../../base/common/objects.js';
import { EventType, EventHelper, addDisposableListener, ModifierKeyEmitter, getActiveElement, hasWindow, getWindow, getWindowById, getWindows } from '../../base/browser/dom.js';
import { EventType, EventHelper, addDisposableListener, ModifierKeyEmitter, getActiveElement, hasWindow, getWindowById, getWindows } from '../../base/browser/dom.js';
import { Action, Separator, WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from '../../base/common/actions.js';
import { IFileService } from '../../platform/files/common/files.js';
import { EditorResourceAccessor, IUntitledTextResourceEditorInput, SideBySideEditor, pathsToEditors, IResourceDiffEditorInput, IUntypedEditorInput, IEditorPane, isResourceEditorInput, IResourceMergeEditorInput } from '../common/editor.js';
Expand Down Expand Up @@ -41,13 +41,12 @@ import { WorkbenchState, IWorkspaceContextService } from '../../platform/workspa
import { coalesce } from '../../base/common/arrays.js';
import { ConfigurationTarget, IConfigurationService } from '../../platform/configuration/common/configuration.js';
import { IStorageService, StorageScope, StorageTarget } from '../../platform/storage/common/storage.js';
import { assertIsDefined } from '../../base/common/types.js';
import { IOpenerService, IResolvedExternalUri, OpenOptions } from '../../platform/opener/common/opener.js';
import { Schemas } from '../../base/common/network.js';
import { INativeHostService } from '../../platform/native/common/native.js';
import { posix } from '../../base/common/path.js';
import { ITunnelService, RemoteTunnel, extractLocalHostUriMetaDataForPortMapping, extractQueryLocalHostUriMetaDataForPortMapping } from '../../platform/tunnel/common/tunnel.js';
import { IWorkbenchLayoutService, Parts, positionFromString, Position } from '../services/layout/browser/layoutService.js';
import { IWorkbenchLayoutService, positionFromString, Position } from '../services/layout/browser/layoutService.js';
import { IWorkingCopyService } from '../services/workingCopy/common/workingCopyService.js';
import { WorkingCopyCapabilities } from '../services/workingCopy/common/workingCopy.js';
import { IFilesConfigurationService } from '../services/filesConfiguration/common/filesConfigurationService.js';
Expand Down Expand Up @@ -397,21 +396,6 @@ export class NativeWindow extends BaseWindow {
this._register(this.editorGroupService.onDidCreateAuxiliaryEditorPart(part => this.handleRepresentedFilename(part)));
}

// Maximize/Restore on doubleclick (for macOS custom title)
if (isMacintosh && !hasNativeTitlebar(this.configurationService)) {
this._register(Event.runAndSubscribe(this.layoutService.onDidAddContainer, ({ container, disposables }) => {
const targetWindow = getWindow(container);
const targetWindowId = targetWindow.vscodeWindowId;
const titlePart = assertIsDefined(this.layoutService.getContainer(targetWindow, Parts.TITLEBAR_PART));

disposables.add(addDisposableListener(titlePart, EventType.DBLCLICK, e => {
EventHelper.stop(e);

this.nativeHostService.handleTitleDoubleClick({ targetWindowId });
}));
}, { container: this.layoutService.mainContainer, disposables: this._store }));
}

// Document edited: indicate for dirty working copies
this._register(this.workingCopyService.onDidChangeDirty(workingCopy => {
const gotDirty = workingCopy.isDirty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export class TestNativeHostService implements INativeHostService {
}

async toggleFullScreen(): Promise<void> { }
async handleTitleDoubleClick(): Promise<void> { }
async isMaximized(): Promise<boolean> { return true; }
async isFullScreen(): Promise<boolean> { return true; }
async maximizeWindow(): Promise<void> { }
Expand Down
Loading