Skip to content

Add tooltips to Window controls #158112

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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: 1 addition & 1 deletion src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
@@ -74,7 +74,7 @@ export class TitlebarPart extends Part implements ITitleService {
private layoutToolbar: MenuWorkbenchToolBar | undefined;
protected lastLayoutDimensions: Dimension | undefined;

private hoverDelegate: IHoverDelegate;
protected hoverDelegate: IHoverDelegate;

private readonly titleDisposables = this._register(new DisposableStore());
private titleBarStyle: 'native' | 'custom';
15 changes: 14 additions & 1 deletion src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { Codicon } from 'vs/base/common/codicons';
import { NativeMenubarControl } from 'vs/workbench/electron-sandbox/parts/titlebar/menubarControl';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { localize } from 'vs/nls';
import { setupCustomHover } from 'vs/base/browser/ui/iconLabel/iconLabelHover';

export class TitlebarPart extends BrowserTitleBarPart {
private maxRestoreControl: HTMLElement | undefined;
@@ -177,7 +179,11 @@ export class TitlebarPart extends BrowserTitleBarPart {
this.nativeHostService.minimizeWindow();
}));

// Restore
this._register(addDisposableListener(minimizeIcon, EventType.MOUSE_OVER, e => {
setupCustomHover(this.hoverDelegate, minimizeIcon, localize('window.minimize', 'Minimize'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setupCustomHover function is already binding to the DOM event, so you don't need the additional event listener on these. You just need to register the result of the function call.

}));

// Maximize - Restore Down
this.maxRestoreControl = append(this.windowControls, $('div.window-icon.window-max-restore'));
this._register(addDisposableListener(this.maxRestoreControl, EventType.CLICK, async e => {
const maximized = await this.nativeHostService.isMaximized();
@@ -187,12 +193,19 @@ export class TitlebarPart extends BrowserTitleBarPart {

return this.nativeHostService.maximizeWindow();
}));
this._register(addDisposableListener(this.maxRestoreControl, EventType.MOUSE_OVER, async e => {
const maximized = await this.nativeHostService.isMaximized();
setupCustomHover(this.hoverDelegate, this.maxRestoreControl!, maximized ? localize('window.restore', 'Restore Down') : localize('window.maximize', 'Maximize'));
}));

// Close
const closeIcon = append(this.windowControls, $('div.window-icon.window-close' + Codicon.chromeClose.cssSelector));
this._register(addDisposableListener(closeIcon, EventType.CLICK, e => {
this.nativeHostService.closeWindow();
}));
this._register(addDisposableListener(closeIcon, EventType.MOUSE_OVER, e => {
setupCustomHover(this.hoverDelegate, closeIcon, localize('window.close', 'Close'));
}));

// Resizer
this.resizer = append(this.rootContainer, $('div.resizer'));