@@ -7,7 +7,7 @@ import 'vs/css!./media/titlebarpart';
7
7
import { localize , localize2 } from 'vs/nls' ;
8
8
import { MultiWindowParts , Part } from 'vs/workbench/browser/part' ;
9
9
import { ITitleService } from 'vs/workbench/services/title/browser/titleService' ;
10
- import { getWCOTitlebarAreaRect , getZoomFactor , isWCOEnabled } from 'vs/base/browser/browser' ;
10
+ import { getWCOTitlebarAreaRect , getZoomFactor , isWCOEnabled , onDidChangeZoomLevel } from 'vs/base/browser/browser' ;
11
11
import { MenuBarVisibility , getTitleBarStyle , getMenuBarVisibility , TitlebarStyle , hasCustomTitlebar , hasNativeTitlebar , DEFAULT_CUSTOM_TITLEBAR_HEIGHT } from 'vs/platform/window/common/window' ;
12
12
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
13
13
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent' ;
@@ -478,34 +478,45 @@ export class BrowserTitlebarPart extends Part implements ITitlebarPart {
478
478
479
479
// Window Controls Container
480
480
if ( ! hasNativeTitlebar ( this . configurationService , this . titleBarStyle ) ) {
481
- let windowControlsLocation = isMacintosh ? 'left' : 'right' ;
481
+ let primaryWindowControlsLocation = isMacintosh ? 'left' : 'right' ;
482
482
if ( isMacintosh && isNative ) {
483
483
484
484
// Check if the locale is RTL, macOS will move traffic lights in RTL locales
485
485
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/textInfo
486
486
487
487
const localeInfo = new Intl . Locale ( platformLocale ) as any ;
488
488
if ( localeInfo ?. textInfo ?. direction === 'rtl' ) {
489
- windowControlsLocation = 'right' ;
489
+ primaryWindowControlsLocation = 'right' ;
490
490
}
491
491
}
492
492
493
- if ( isMacintosh && isNative && windowControlsLocation === 'left' ) {
493
+ if ( isMacintosh && isNative && primaryWindowControlsLocation === 'left' ) {
494
494
// macOS native: controls are on the left and the container is not needed to make room
495
495
// for something, except for web where a custom menu being supported). not putting the
496
496
// container helps with allowing to move the window when clicking very close to the
497
497
// window control buttons.
498
498
} else {
499
- this . windowControlsContainer = append ( windowControlsLocation === 'left' ? this . leftContent : this . rightContent , $ ( 'div.window-controls-container' ) ) ;
499
+ this . windowControlsContainer = append ( primaryWindowControlsLocation === 'left' ? this . leftContent : this . rightContent , $ ( 'div.window-controls-container' ) ) ;
500
+ if ( isWeb ) {
501
+ // Web: its possible to have control overlays on both sides, for example on macOS
502
+ // with window controls on the left and PWA controls on the right.
503
+ append ( primaryWindowControlsLocation === 'left' ? this . rightContent : this . leftContent , $ ( 'div.window-controls-container' ) ) ;
504
+ }
505
+
500
506
if ( isWCOEnabled ( ) ) {
501
507
this . windowControlsContainer . classList . add ( 'wco-enabled' ) ;
502
508
503
- const targetWindow = getWindow ( this . element ) ;
504
- const wcoTitlebarAreaRect = getWCOTitlebarAreaRect ( targetWindow ) ;
505
- if ( wcoTitlebarAreaRect ) {
506
- const wcoWidth = targetWindow . innerWidth - wcoTitlebarAreaRect . width - wcoTitlebarAreaRect . x ;
507
- this . windowControlsContainer . style . setProperty ( '--title-wco-width' , `${ wcoWidth } px` ) ;
508
- }
509
+ const updateWCOWidthVariable = ( ) => {
510
+ const targetWindow = getWindow ( this . element ) ;
511
+ const wcoTitlebarAreaRect = getWCOTitlebarAreaRect ( targetWindow ) ;
512
+ if ( wcoTitlebarAreaRect ) {
513
+ const wcoWidth = targetWindow . innerWidth - wcoTitlebarAreaRect . width - wcoTitlebarAreaRect . x ;
514
+ this . windowControlsContainer ?. style . setProperty ( '--title-wco-width' , `${ wcoWidth } px` ) ;
515
+ }
516
+ } ;
517
+ updateWCOWidthVariable ( ) ;
518
+
519
+ this . _register ( onDidChangeZoomLevel ( ( ) => setTimeout ( ( ) => updateWCOWidthVariable ( ) , 5 ) ) ) ; // Somehow it does not get the right size without this timeout :-/
509
520
}
510
521
}
511
522
}
0 commit comments