@@ -10,6 +10,7 @@ import { IContextKeyService } from '../../../platform/contextkey/common/contextk
1010import { IContextMenuService } from '../../../platform/contextview/browser/contextView.js' ;
1111import { IInstantiationService } from '../../../platform/instantiation/common/instantiation.js' ;
1212import { INativeHostService } from '../../../platform/native/common/native.js' ;
13+ import { IProductService } from '../../../platform/product/common/productService.js' ;
1314import { IStorageService } from '../../../platform/storage/common/storage.js' ;
1415import { IThemeService } from '../../../platform/theme/common/themeService.js' ;
1516import { useWindowControlsOverlay } from '../../../platform/window/common/window.js' ;
@@ -20,6 +21,7 @@ import { IAuxiliaryTitlebarPart } from '../../../workbench/browser/parts/titleba
2021import { IEditorGroupsContainer } from '../../../workbench/services/editor/common/editorGroupsService.js' ;
2122import { CodeWindow , mainWindow } from '../../../base/browser/window.js' ;
2223import { TitlebarPart , TitleService } from '../../browser/parts/titlebarPart.js' ;
24+ import { isMacintosh } from '../../../base/common/platform.js' ;
2325
2426export class NativeTitlebarPart extends TitlebarPart {
2527
@@ -37,13 +39,32 @@ export class NativeTitlebarPart extends TitlebarPart {
3739 @IWorkbenchLayoutService layoutService : IWorkbenchLayoutService ,
3840 @IContextKeyService contextKeyService : IContextKeyService ,
3941 @IHostService hostService : IHostService ,
42+ @IProductService private readonly productService : IProductService ,
4043 @INativeHostService private readonly nativeHostService : INativeHostService ,
4144 ) {
4245 super ( id , targetWindow , contextMenuService , configurationService , instantiationService , themeService , storageService , layoutService , contextKeyService , hostService ) ;
4346
4447 this . handleWindowsAlwaysOnTop ( targetWindow . vscodeWindowId , contextKeyService ) ;
4548 }
4649
50+ protected override createContentArea ( parent : HTMLElement ) : HTMLElement {
51+
52+ // Workaround for macOS/Electron bug where the window does not
53+ // appear in the "Windows" menu if the first `document.title`
54+ // matches the BrowserWindow's initial title.
55+ // See: https://github.com/microsoft/vscode/issues/191288
56+ if ( isMacintosh ) {
57+ const window = getWindow ( this . element ) ;
58+ const nativeTitle = this . productService . nameLong ;
59+ if ( ! window . document . title || window . document . title === nativeTitle ) {
60+ window . document . title = `${ nativeTitle } \u200b` ;
61+ }
62+ window . document . title = nativeTitle ;
63+ }
64+
65+ return super . createContentArea ( parent ) ;
66+ }
67+
4768 private async handleWindowsAlwaysOnTop ( targetWindowId : number , contextKeyService : IContextKeyService ) : Promise < void > {
4869 const isWindowAlwaysOnTopContext = IsWindowAlwaysOnTopContext . bindTo ( contextKeyService ) ;
4970
@@ -107,9 +128,10 @@ class MainNativeTitlebarPart extends NativeTitlebarPart {
107128 @IWorkbenchLayoutService layoutService : IWorkbenchLayoutService ,
108129 @IContextKeyService contextKeyService : IContextKeyService ,
109130 @IHostService hostService : IHostService ,
131+ @IProductService productService : IProductService ,
110132 @INativeHostService nativeHostService : INativeHostService ,
111133 ) {
112- super ( Parts . TITLEBAR_PART , mainWindow , contextMenuService , configurationService , instantiationService , themeService , storageService , layoutService , contextKeyService , hostService , nativeHostService ) ;
134+ super ( Parts . TITLEBAR_PART , mainWindow , contextMenuService , configurationService , instantiationService , themeService , storageService , layoutService , contextKeyService , hostService , productService , nativeHostService ) ;
113135 }
114136}
115137
@@ -130,10 +152,11 @@ class AuxiliaryNativeTitlebarPart extends NativeTitlebarPart implements IAuxilia
130152 @IWorkbenchLayoutService layoutService : IWorkbenchLayoutService ,
131153 @IContextKeyService contextKeyService : IContextKeyService ,
132154 @IHostService hostService : IHostService ,
155+ @IProductService productService : IProductService ,
133156 @INativeHostService nativeHostService : INativeHostService ,
134157 ) {
135158 const id = AuxiliaryNativeTitlebarPart . COUNTER ++ ;
136- super ( `workbench.parts.auxiliaryTitle.${ id } ` , getWindow ( container ) , contextMenuService , configurationService , instantiationService , themeService , storageService , layoutService , contextKeyService , hostService , nativeHostService ) ;
159+ super ( `workbench.parts.auxiliaryTitle.${ id } ` , getWindow ( container ) , contextMenuService , configurationService , instantiationService , themeService , storageService , layoutService , contextKeyService , hostService , productService , nativeHostService ) ;
137160 }
138161
139162 override get preventZoom ( ) : boolean {
0 commit comments