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

Dimm WCO when dialog opens #236080

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import { DialogService } from '../../../services/dialogs/common/dialogService.js
import { Disposable } from '../../../../base/common/lifecycle.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { Lazy } from '../../../../base/common/lazy.js';
import { INativeHostService } from '../../../../platform/native/common/native.js';
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
import { IHostService } from '../../../services/host/browser/host.js';

export class DialogHandlerContribution extends Disposable implements IWorkbenchContribution {

Expand All @@ -33,11 +36,14 @@ export class DialogHandlerContribution extends Disposable implements IWorkbenchC
@IKeybindingService keybindingService: IKeybindingService,
@IInstantiationService instantiationService: IInstantiationService,
@IProductService productService: IProductService,
@IClipboardService clipboardService: IClipboardService
@IClipboardService clipboardService: IClipboardService,
@INativeHostService nativeHostService: INativeHostService,
Copy link
Member

Choose a reason for hiding this comment

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

Native host service is Electron only, not web.

@IHostService hostService: IHostService,
@IThemeService themeService: IThemeService
) {
super();

this.impl = new Lazy(() => new BrowserDialogHandler(logService, layoutService, keybindingService, instantiationService, productService, clipboardService));
this.impl = new Lazy(() => new BrowserDialogHandler(logService, layoutService, keybindingService, instantiationService, productService, clipboardService, nativeHostService, hostService, themeService));

this.model = (this.dialogService as DialogService).model;

Expand Down
35 changes: 33 additions & 2 deletions src/vs/workbench/browser/parts/dialogs/dialogHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ILayoutService } from '../../../../platform/layout/browser/layoutServic
import { ILogService } from '../../../../platform/log/common/log.js';
import Severity from '../../../../base/common/severity.js';
import { Dialog, IDialogResult } from '../../../../base/browser/ui/dialog/dialog.js';
import { DisposableStore } from '../../../../base/common/lifecycle.js';
import { DisposableStore, toDisposable } from '../../../../base/common/lifecycle.js';
import { StandardKeyboardEvent } from '../../../../base/browser/keyboardEvent.js';
import { EventHelper } from '../../../../base/browser/dom.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
Expand All @@ -21,6 +21,11 @@ import { MarkdownRenderer } from '../../../../editor/browser/widget/markdownRend
import { defaultButtonStyles, defaultCheckboxStyles, defaultDialogStyles, defaultInputBoxStyles } from '../../../../platform/theme/browser/defaultStyles.js';
import { ResultKind } from '../../../../platform/keybinding/common/keybindingResolver.js';
import { CancellationToken } from '../../../../base/common/cancellation.js';
import { INativeHostService } from '../../../../platform/native/common/native.js';
import { TITLE_BAR_ACTIVE_BACKGROUND, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_BACKGROUND, TITLE_BAR_INACTIVE_FOREGROUND } from '../../../common/theme.js';
import { Color, RGBA } from '../../../../base/common/color.js';
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
import { IHostService } from '../../../services/host/browser/host.js';

export class BrowserDialogHandler extends AbstractDialogHandler {

Expand All @@ -41,7 +46,10 @@ export class BrowserDialogHandler extends AbstractDialogHandler {
@IKeybindingService private readonly keybindingService: IKeybindingService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IProductService private readonly productService: IProductService,
@IClipboardService private readonly clipboardService: IClipboardService
@IClipboardService private readonly clipboardService: IClipboardService,
@INativeHostService private readonly nativeHostService: INativeHostService,
@IHostService private readonly hostService: IHostService,
@IThemeService private readonly themeService: IThemeService
) {
super();
}
Expand Down Expand Up @@ -152,6 +160,29 @@ export class BrowserDialogHandler extends AbstractDialogHandler {

dialogDisposables.add(dialog);

// Change WCO to match dimmed background
const setWCOColors = (windowIsActive: boolean, dimmed: boolean) => {
const theme = this.themeService.getColorTheme();
const titleBarForegroundColor = theme.getColor(windowIsActive ? TITLE_BAR_ACTIVE_FOREGROUND : TITLE_BAR_INACTIVE_FOREGROUND);
const titleBarBackgroundColor = theme.getColor(windowIsActive ? TITLE_BAR_ACTIVE_BACKGROUND : TITLE_BAR_INACTIVE_BACKGROUND);
if (!titleBarForegroundColor || !titleBarBackgroundColor) {
return;
}

const overlayColor = new Color(new RGBA(0, 0, 0, 0.3));
const backgroundColor = dimmed ? overlayColor.makeOpaque(titleBarBackgroundColor) : titleBarBackgroundColor;
const foregroundColor = dimmed ? overlayColor.makeOpaque(titleBarForegroundColor) : titleBarForegroundColor;

Copy link
Member

Choose a reason for hiding this comment

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

Is this taken from somewhere were we already dim buttons or is this new? We still have custom window buttons around here:

if (isLinux && !hasNativeTitlebar(this.configurationService) && !isWCOEnabled() && this.windowControlsContainer) {

this.nativeHostService.updateWindowControls({
backgroundColor: backgroundColor.toString(),
foregroundColor: foregroundColor.toString()
});
};

setWCOColors(this.hostService.hasFocus, true);
dialogDisposables.add(this.hostService.onDidChangeFocus(focused => setWCOColors(focused, true)));
dialogDisposables.add(toDisposable(() => { setWCOColors(this.hostService.hasFocus, false); }));

const result = await dialog.show();
dialogDisposables.dispose();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { DialogService } from '../../../services/dialogs/common/dialogService.js
import { Disposable } from '../../../../base/common/lifecycle.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { Lazy } from '../../../../base/common/lazy.js';
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
import { IHostService } from '../../../services/host/browser/host.js';

export class DialogHandlerContribution extends Disposable implements IWorkbenchContribution {

Expand All @@ -39,11 +41,13 @@ export class DialogHandlerContribution extends Disposable implements IWorkbenchC
@IInstantiationService instantiationService: IInstantiationService,
@IProductService productService: IProductService,
@IClipboardService clipboardService: IClipboardService,
@INativeHostService nativeHostService: INativeHostService
@INativeHostService nativeHostService: INativeHostService,
@IHostService hostService: IHostService,
@IThemeService themeService: IThemeService
) {
super();

this.browserImpl = new Lazy(() => new BrowserDialogHandler(logService, layoutService, keybindingService, instantiationService, productService, clipboardService));
this.browserImpl = new Lazy(() => new BrowserDialogHandler(logService, layoutService, keybindingService, instantiationService, productService, clipboardService, nativeHostService, hostService, themeService));
this.nativeImpl = new Lazy(() => new NativeDialogHandler(logService, nativeHostService, productService, clipboardService));

this.model = (this.dialogService as DialogService).model;
Expand Down
Loading